From 0d5f0147d473aeac09bd67c7ef90ae8b332df0a8 Mon Sep 17 00:00:00 2001 From: Dave Marion Date: Mon, 23 Dec 2024 13:16:47 +0000 Subject: [PATCH] Halt VM is lock lost but shutdown not complete --- .../main/java/org/apache/accumulo/compactor/Compactor.java | 6 +++++- .../main/java/org/apache/accumulo/tserver/TabletServer.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java b/server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java index 6ec8ba1ba2d..0488032368a 100644 --- a/server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java +++ b/server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java @@ -170,6 +170,7 @@ public String getQueueName() { private ServerAddress compactorAddress = null; private final AtomicBoolean compactionRunning = new AtomicBoolean(false); + private volatile boolean shutdownComplete = false; protected Compactor(CompactorServerOpts opts, String[] args) { super("compactor", opts, args); @@ -287,7 +288,9 @@ protected void announceExistence(HostAndPort clientAddress) LockWatcher lw = new LockWatcher() { @Override public void lostLock(final LockLossReason reason) { - if (isShutdownRequested()) { + // ServiceLock.unlock is called at the end of run(). We don't + // want to Halt when we are shutting down. + if (isShutdownRequested() && shutdownComplete) { LOG.warn("Compactor lost lock (reason = {}), not exiting because shutdown requested.", reason); } else { @@ -905,6 +908,7 @@ public void run() { gcLogger.logGCInfo(getConfiguration()); LOG.info("stop requested. exiting ... "); + shutdownComplete = true; try { if (null != compactorLock) { compactorLock.unlock(); diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java index 3759575c59d..00cbaf4ab2f 100644 --- a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java @@ -240,6 +240,7 @@ public TabletServerMinCMetrics getMinCMetrics() { private final ZooAuthenticationKeyWatcher authKeyWatcher; private final WalStateManager walMarker; private final ServerContext context; + private volatile boolean shutdownComplete = false; public static void main(String[] args) throws Exception { try (TabletServer tserver = new TabletServer(new ServerOpts(), args)) { @@ -686,7 +687,9 @@ private void announceExistence() { @Override public void lostLock(final LockLossReason reason) { - if (isShutdownRequested()) { + // ServiceLock.unlock is called at the end of run(). We don't + // want to Halt when we are shutting down. + if (isShutdownRequested() && shutdownComplete) { LOG.warn( "TabletServer lost lock (reason = {}), not exiting because shutdown requested.", reason); @@ -1027,6 +1030,7 @@ public void run() { log.info("TServerInfo: stop requested. exiting ... "); + shutdownComplete = true; try { tabletServerLock.unlock(); } catch (Exception e) {