Skip to content

Commit

Permalink
Fix failing ITs
Browse files Browse the repository at this point in the history
  • Loading branch information
adejanovski committed Dec 17, 2024
1 parent 139464a commit ab963a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class ReplicaLockManagerWithTtl {

private final ConcurrentHashMap<String, LockInfo> replicaLocks = new ConcurrentHashMap<>();
private final ConcurrentHashMap<UUID, Set<UUID>> repairRunToSegmentLocks = new ConcurrentHashMap<>();
private final ConcurrentHashMap<UUID, ReentrantLock> runIdLocks = new ConcurrentHashMap<>();
private final Lock lock = new ReentrantLock();

private final long ttlMilliSeconds;

Expand All @@ -47,12 +47,7 @@ private String getReplicaLockKey(String replica, UUID runId) {
return replica + runId;
}

private Lock getLockForRunId(UUID runId) {
return runIdLocks.computeIfAbsent(runId, k -> new ReentrantLock());
}

public boolean lockRunningRepairsForNodes(UUID runId, UUID segmentId, Set<String> replicas) {
Lock lock = getLockForRunId(runId);
lock.lock();
try {
long currentTime = System.currentTimeMillis();
Expand Down Expand Up @@ -81,7 +76,6 @@ public boolean lockRunningRepairsForNodes(UUID runId, UUID segmentId, Set<String
}

public boolean renewRunningRepairsForNodes(UUID runId, UUID segmentId, Set<String> replicas) {
Lock lock = getLockForRunId(runId);
lock.lock();
try {
long currentTime = System.currentTimeMillis();
Expand Down Expand Up @@ -111,7 +105,6 @@ public boolean renewRunningRepairsForNodes(UUID runId, UUID segmentId, Set<Strin
}

public boolean releaseRunningRepairsForNodes(UUID runId, UUID segmentId, Set<String> replicas) {
Lock lock = getLockForRunId(runId);
lock.lock();
try {
// Remove the lock for replicas
Expand Down Expand Up @@ -141,7 +134,7 @@ public Set<UUID> getLockedSegmentsForRun(UUID runId) {

@VisibleForTesting
public void cleanupExpiredLocks() {
runIdLocks.values().forEach(Lock::lock);
lock.lock();
try {
long currentTime = System.currentTimeMillis();

Expand All @@ -162,7 +155,7 @@ public void cleanupExpiredLocks() {
return segments.isEmpty();
});
} finally {
runIdLocks.values().forEach(Lock::unlock);
lock.unlock();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ public static void tearDown() {
}

public static void deleteFolderContents(String folderPath) throws IOException {
// Check if the path exists
Path path = Paths.get(folderPath);
if (!Files.exists(path)) {
return;
}
try (Stream<Path> walk = Files.walk(path)) {
walk.sorted(Comparator.reverseOrder())
.forEach(p -> {
Expand Down

0 comments on commit ab963a7

Please sign in to comment.