Skip to content

Commit

Permalink
Halt VM is lock lost but shutdown not complete
Browse files Browse the repository at this point in the history
  • Loading branch information
dlmarion committed Dec 23, 2024
1 parent c09918e commit 0d5f014
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -905,6 +908,7 @@ public void run() {

gcLogger.logGCInfo(getConfiguration());
LOG.info("stop requested. exiting ... ");
shutdownComplete = true;
try {
if (null != compactorLock) {
compactorLock.unlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1027,6 +1030,7 @@ public void run() {

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

shutdownComplete = true;
try {
tabletServerLock.unlock();
} catch (Exception e) {
Expand Down

0 comments on commit 0d5f014

Please sign in to comment.