From 44b97f36c418d1cb505961ad2493462bf5134348 Mon Sep 17 00:00:00 2001 From: Dave Marion Date: Thu, 2 Jan 2025 16:09:50 -0500 Subject: [PATCH] Better handling for ignored interrupted exceptions (#5212) Closes #5203 Co-authored-by: Christopher Tubbs --- .../fate/zookeeper/DistributedReadWriteLock.java | 3 ++- .../org/apache/accumulo/server/util/Admin.java | 14 ++++++++++++-- .../accumulo/tserver/log/TabletServerLogger.java | 12 +++++++++--- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/DistributedReadWriteLock.java b/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/DistributedReadWriteLock.java index 6f9dc1f107f..da27d408a08 100644 --- a/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/DistributedReadWriteLock.java +++ b/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/DistributedReadWriteLock.java @@ -137,7 +137,8 @@ public void lock() { return; } } catch (InterruptedException ex) { - // ignored + Thread.currentThread().interrupt(); + log.warn("Interrupted while waiting to acquire lock", ex); } } } diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java b/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java index ac35bc0f17e..83f8ba4a4f4 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java @@ -494,7 +494,8 @@ 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) { @@ -502,7 +503,8 @@ private static void flushAll(final ClientContext context) { 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()) { @@ -510,6 +512,14 @@ private static void flushAll(final ClientContext context) { 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) diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/log/TabletServerLogger.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/log/TabletServerLogger.java index a124c634f34..46970b4c213 100644 --- a/server/tserver/src/main/java/org/apache/accumulo/tserver/log/TabletServerLogger.java +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/log/TabletServerLogger.java @@ -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; @@ -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; @@ -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); } } }