Skip to content

Commit

Permalink
[UT] Optimize the logic of assertDeadLock to reduce UT failures (Star…
Browse files Browse the repository at this point in the history
…Rocks#51776)

Signed-off-by: HangyuanLiu <460660596@qq.com>
  • Loading branch information
HangyuanLiu authored Nov 14, 2024
1 parent 3fb71a5 commit 845891e
Showing 1 changed file with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,30 @@ public static int assertDeadLock(List<TestLocker> testLockers,
assertLockSuccess(testLockers.get(deadLockIdx).release(rids.get(deadLockIdx).first, rids.get(deadLockIdx).second));

boolean hasSuccess = false;
for (int i = 0; i < waitLockers.size(); ++i) {
if (i == deadLockIdx) {
continue;
}
Future<LockResult> waitLocker = waitLockers.get(i);
int retryTimes = 5;
while (retryTimes-- > 0) {
for (int i = 0; i < waitLockers.size(); ++i) {
if (i == deadLockIdx) {
continue;
}
Future<LockResult> waitLocker = waitLockers.get(i);

try {
LockResult lockResult = waitLocker.get();
if (LockResult.LockTaskResultType.SUCCESS.equals(lockResult.resultType)) {
hasSuccess = true;
try {
LockResult lockResult = waitLocker.get();
if (LockResult.LockTaskResultType.SUCCESS.equals(lockResult.resultType)) {
hasSuccess = true;
break;
} else {
System.out.println("LockResult" + retryTimes + " : " + lockResult.resultType);
}

} catch (ExecutionException | InterruptedException e) {
throw new RuntimeException(e);
}
} catch (ExecutionException | InterruptedException e) {
throw new RuntimeException(e);
}

if (hasSuccess) {
break;
}
}

Expand Down

0 comments on commit 845891e

Please sign in to comment.