Skip to content

Commit

Permalink
fix AbortPolicyWithReport Semaphore lock not released (#13609)
Browse files Browse the repository at this point in the history
Co-authored-by: wuzihan <wuzihan@youzan.com>
  • Loading branch information
CycleMaker and wuzihan authored Jan 8, 2024
1 parent ec47f80 commit 670f997
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ private void dumpJStack() {
if (!guard.tryAcquire()) {
return;
}
// To avoid multiple dump, check again
if (System.currentTimeMillis() - lastPrintTime < TEN_MINUTES_MILLS) {
return;
}

ExecutorService pool = Executors.newSingleThreadExecutor();
ExecutorService pool = null;
try {
// To avoid multiple dump, check again
if (System.currentTimeMillis() - lastPrintTime < TEN_MINUTES_MILLS) {
return;
}
pool = Executors.newSingleThreadExecutor();
pool.execute(() -> {
String dumpPath = getDumpPath();

Expand All @@ -186,12 +186,14 @@ private void dumpJStack() {
logger.error(COMMON_UNEXPECTED_CREATE_DUMP, "", "", "dump jStack error", t);
} finally {
lastPrintTime = System.currentTimeMillis();
guard.release();
}
});
} finally {
guard.release();
// must shutdown thread pool ,if not will lead to OOM
pool.shutdown();
if (pool != null) {
pool.shutdown();
}
}
}

Expand Down

0 comments on commit 670f997

Please sign in to comment.