You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by ch...@apache.org on 2023/12/04 03:46:08 UTC

(bookkeeper) branch master updated: Fix a slow gc thread shutdown when compacting (#4127)

This is an automated email from the ASF dual-hosted git repository.

chenhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new a842f3e92c Fix a slow gc thread shutdown when compacting (#4127)
a842f3e92c is described below

commit a842f3e92cbe7c9a99f72567af19b8f7c4ce7e82
Author: erobot <er...@users.noreply.github.com>
AuthorDate: Mon Dec 4 11:46:02 2023 +0800

    Fix a slow gc thread shutdown when compacting (#4127)
    
    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: #4126
---
 .../main/java/org/apache/bookkeeper/bookie/GarbageCollectorThread.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/GarbageCollectorThread.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/GarbageCollectorThread.java
index d5cde9b434..bc55af1fe2 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/GarbageCollectorThread.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/GarbageCollectorThread.java
@@ -679,6 +679,7 @@ public class GarbageCollectorThread implements Runnable {
         if (!this.running) {
             return;
         }
+        this.running = false;
         LOG.info("Shutting down GarbageCollectorThread");
 
         throttler.cancelledAcquire();
@@ -688,7 +689,6 @@ public class GarbageCollectorThread implements Runnable {
             Thread.sleep(100);
         }
 
-        this.running = false;
         // Interrupt GC executor thread
         gcExecutor.shutdownNow();
         try {