You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by ni...@apache.org on 2022/09/20 08:12:43 UTC

[bookkeeper] 20/25: AutoRecovery - Do not call shutdown() on the main ZookKeeper client thread (#3487)

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

nicoloboschi pushed a commit to branch ds-4.14
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git

commit 3ee8d2357c708715871f417035b8db55132b8e71
Author: Enrico Olivelli <eo...@apache.org>
AuthorDate: Wed Sep 14 22:09:57 2022 +0200

    AutoRecovery - Do not call shutdown() on the main ZookKeeper client thread (#3487)
    
    (cherry picked from commit 6fc2e08d534159fc078022a6781e94933b7268d1)
---
 .../java/org/apache/bookkeeper/replication/AutoRecoveryMain.java   | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AutoRecoveryMain.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AutoRecoveryMain.java
index 1ccb322826..4fea7e809b 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AutoRecoveryMain.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AutoRecoveryMain.java
@@ -29,6 +29,7 @@ import java.io.File;
 import java.io.IOException;
 import java.lang.Thread.UncaughtExceptionHandler;
 import java.net.MalformedURLException;
+import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ExecutionException;
 
 import org.apache.bookkeeper.bookie.Bookie;
@@ -96,7 +97,11 @@ public class AutoRecoveryMain {
         MetadataClientDriver metadataClientDriver = bkc.getMetadataClientDriver();
         metadataClientDriver.setSessionStateListener(() -> {
             LOG.error("Client connection to the Metadata server has expired, so shutting down AutoRecoveryMain!");
-            shutdown(ExitCode.ZK_EXPIRED);
+            // do not run "shutdown" in the main ZooKeeper client thread
+            // as it performs some blocking operations
+            CompletableFuture.runAsync(() -> {
+                shutdown(ExitCode.ZK_EXPIRED);
+            });
         });
 
         auditorElector = new AuditorElector(