Skip to content

Commit 0d5f014

Browse files
committed
Halt VM is lock lost but shutdown not complete
1 parent c09918e commit 0d5f014

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ public String getQueueName() {
170170
private ServerAddress compactorAddress = null;
171171

172172
private final AtomicBoolean compactionRunning = new AtomicBoolean(false);
173+
private volatile boolean shutdownComplete = false;
173174

174175
protected Compactor(CompactorServerOpts opts, String[] args) {
175176
super("compactor", opts, args);
@@ -287,7 +288,9 @@ protected void announceExistence(HostAndPort clientAddress)
287288
LockWatcher lw = new LockWatcher() {
288289
@Override
289290
public void lostLock(final LockLossReason reason) {
290-
if (isShutdownRequested()) {
291+
// ServiceLock.unlock is called at the end of run(). We don't
292+
// want to Halt when we are shutting down.
293+
if (isShutdownRequested() && shutdownComplete) {
291294
LOG.warn("Compactor lost lock (reason = {}), not exiting because shutdown requested.",
292295
reason);
293296
} else {
@@ -905,6 +908,7 @@ public void run() {
905908

906909
gcLogger.logGCInfo(getConfiguration());
907910
LOG.info("stop requested. exiting ... ");
911+
shutdownComplete = true;
908912
try {
909913
if (null != compactorLock) {
910914
compactorLock.unlock();

server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ public TabletServerMinCMetrics getMinCMetrics() {
240240
private final ZooAuthenticationKeyWatcher authKeyWatcher;
241241
private final WalStateManager walMarker;
242242
private final ServerContext context;
243+
private volatile boolean shutdownComplete = false;
243244

244245
public static void main(String[] args) throws Exception {
245246
try (TabletServer tserver = new TabletServer(new ServerOpts(), args)) {
@@ -686,7 +687,9 @@ private void announceExistence() {
686687

687688
@Override
688689
public void lostLock(final LockLossReason reason) {
689-
if (isShutdownRequested()) {
690+
// ServiceLock.unlock is called at the end of run(). We don't
691+
// want to Halt when we are shutting down.
692+
if (isShutdownRequested() && shutdownComplete) {
690693
LOG.warn(
691694
"TabletServer lost lock (reason = {}), not exiting because shutdown requested.",
692695
reason);
@@ -1027,6 +1030,7 @@ public void run() {
10271030

10281031
log.info("TServerInfo: stop requested. exiting ... ");
10291032

1033+
shutdownComplete = true;
10301034
try {
10311035
tabletServerLock.unlock();
10321036
} catch (Exception e) {

0 commit comments

Comments
 (0)