From 6a40867804ab968f3daa645dbc3b0aebdfa48eec Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 17 Oct 2022 13:26:09 -0700 Subject: [PATCH] =?UTF-8?q?HBASE-27426=20-=20Fix=20ZKWatcher=20shutdown=20?= =?UTF-8?q?seqence=20to=20avoid=20InterruptExcept=E2=80=A6=20(#4829)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andrew Purtell Signed-off-by: Viraj Jasani Co-authored-by: Victor Li --- .../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(); + } } }