Skip to content

Commit

Permalink
Better handling for ignored interrupted exceptions (apache#5212)
Browse files Browse the repository at this point in the history
Closes apache#5203


Co-authored-by: Christopher Tubbs <[email protected]>
  • Loading branch information
dlmarion and ctubbsii authored Jan 2, 2025
1 parent b1510c3 commit 44b97f3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ public void lock() {
return;
}
} catch (InterruptedException ex) {
// ignored
Thread.currentThread().interrupt();
log.warn("Interrupted while waiting to acquire lock", ex);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,22 +494,32 @@ private static void flushAll(final ClientContext context) {
try {
flusher.join(3000);
} catch (InterruptedException e) {
// ignore
Thread.currentThread().interrupt();
log.warn("Interrupted while waiting to join Flush thread", e);
}

while (flusher.isAlive() && System.currentTimeMillis() - start < 15000) {
int flushCount = flushesStarted.get();
try {
flusher.join(1000);
} catch (InterruptedException e) {
// ignore
Thread.currentThread().interrupt();
log.warn("Interrupted while waiting to join Flush thread", e);
}

if (flushCount == flushesStarted.get()) {
// no progress was made while waiting for join... maybe its stuck, stop waiting on it
break;
}
}

flusher.interrupt();
try {
flusher.join();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
log.warn("Interrupted while waiting to join Flush thread", e);
}
}

private static void stopServer(final ClientContext context, final boolean tabletServersToo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ public void run() {
try {
nextLog.offer(t, 12, TimeUnit.HOURS);
} catch (InterruptedException ex) {
// ignore
// Throw an Error, not an Exception, so the AccumuloUncaughtExceptionHandler
// will log this then halt the VM.
throw new Error("Next log maker thread interrupted", ex);
}

continue;
Expand Down Expand Up @@ -337,7 +339,9 @@ public void run() {
try {
nextLog.offer(t, 12, TimeUnit.HOURS);
} catch (InterruptedException ex) {
// ignore
// Throw an Error, not an Exception, so the AccumuloUncaughtExceptionHandler
// will log this then halt the VM.
throw new Error("Next log maker thread interrupted", ex);
}

continue;
Expand All @@ -348,7 +352,9 @@ public void run() {
log.info("Our WAL was not used for 12 hours: {}", fileName);
}
} catch (InterruptedException e) {
// ignore - server is shutting down
// Throw an Error, not an Exception, so the AccumuloUncaughtExceptionHandler
// will log this then halt the VM.
throw new Error("Next log maker thread interrupted", e);
}
}
}
Expand Down

0 comments on commit 44b97f3

Please sign in to comment.