From 39c596fe7a08a5af2ed381993f6c9acb936ec265 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 1fc5fa3ddb77..f6bff0562713 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 @@ -730,12 +730,20 @@ public void interruptedExceptionNoThrow(InterruptedException ie, boolean throwLa */ @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(); + } } }