Skip to content

Commit

Permalink
Fix a slow gc thread shutdown when compacting (apache#4127)
Browse files Browse the repository at this point in the history
Descriptions of the changes in this PR:

### Motivation

Fix a slow gc thread shutdown when compacting.

The problem here is that the stop flag `running` has been moved after `compacting.compareAndSet`. When `running` is not set to false, entry log continues to compact one after one and the shutdown thread is hard to set the `compacting`.

### Changes

Set `running` to false first and then check `compacting`.

Master Issue: apache#4126
  • Loading branch information
erobot authored Dec 4, 2023
1 parent 2c2c583 commit a842f3e
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ public synchronized void shutdown() throws InterruptedException {
if (!this.running) {
return;
}
this.running = false;
LOG.info("Shutting down GarbageCollectorThread");

throttler.cancelledAcquire();
Expand All @@ -688,7 +689,6 @@ public synchronized void shutdown() throws InterruptedException {
Thread.sleep(100);
}

this.running = false;
// Interrupt GC executor thread
gcExecutor.shutdownNow();
try {
Expand Down

0 comments on commit a842f3e

Please sign in to comment.