You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2022/10/17 21:31:12 UTC

[hbase] 01/02: HBASE-27426 - Fix ZKWatcher shutdown seqence to avoid InterruptExcept… (#4829)

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

apurtell pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git

commit 2d95ce072e60f5894d1c2a580f550a54bf303fd0
Author: Victor <vl...@gmail.com>
AuthorDate: Mon Oct 17 13:26:09 2022 -0700

    HBASE-27426 - Fix ZKWatcher shutdown seqence to avoid InterruptExcept… (#4829)
    
    Signed-off-by: Andrew Purtell <ap...@apache.org>
    Signed-off-by: Viraj Jasani <vj...@apache.org>
    Co-authored-by: Victor Li <vi...@salesforce.com>
---
 .../java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java    | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java
index 9608ffc17c6..f499d0f9487 100644
--- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java
+++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java
@@ -735,12 +735,20 @@ public class ZKWatcher implements Watcher, Abortable, Closeable {
    */
   @Override
   public void close() {
+    zkEventProcessor.shutdown();
     try {
-      recoverableZooKeeper.close();
+      if (!zkEventProcessor.awaitTermination(15, TimeUnit.SECONDS)) {
+        LOG.warn("ZKWatcher event processor has not finished to terminate.");
+        zkEventProcessor.shutdownNow();
+      }
     } catch (InterruptedException e) {
       Thread.currentThread().interrupt();
     } finally {
-      zkEventProcessor.shutdownNow();
+      try {
+        recoverableZooKeeper.close();
+      } catch (InterruptedException e) {
+        Thread.currentThread().interrupt();
+      }
     }
   }