Skip to content

Commit

Permalink
add retry
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkPotato777 committed Jan 16, 2025
1 parent 792ca38 commit 1e2373a
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,22 @@ public void killAllSessions(ConnectionSession connectionSession, Predicate<OdcDB
// do nothing
}
}

List<OdcDBSession> checkedList = getSessionList(connectionSession, filter);
if (CollectionUtils.isNotEmpty(checkedList)) {
throw new IllegalStateException("kill session failed, has session reserved");
long startTimeMs = System.currentTimeMillis();
long endTimeMs = startTimeMs + 1500L;
while (System.currentTimeMillis() < endTimeMs) {
List<OdcDBSession> checkedList = getSessionList(connectionSession, filter);
if (CollectionUtils.isEmpty(getSessionList(connectionSession, filter))) {
log.info("All sessions killed, elapsed time: {}ms", System.currentTimeMillis() - startTimeMs);
return;
}
log.info("Has sessions reserved:{}", checkedList);
try {
Thread.sleep(100);
} catch (InterruptedException e) {
log.warn("Thread sleep interrupted", e);
}
}
throw new IllegalStateException("kill session failed, has session reserved");
}

private List<KillResult> doKill(ConnectionSession session, Map<String, String> connectionId2KillSqls) {
Expand Down

0 comments on commit 1e2373a

Please sign in to comment.