From f4cac8ba07799b2bd6fe5dc66ce8f5ddcd7b5d9e Mon Sep 17 00:00:00 2001 From: Victor Li Date: Wed, 12 Oct 2022 16:19:05 -0700 Subject: [PATCH 1/5] HBASE-27426 - Fix ZKWatcher shutdown seqence to avoid InterruptException. --- .../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 9608ffc17c69..98e5fb04d043 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,13 +735,21 @@ public void interruptedExceptionNoThrow(InterruptedException ie, boolean throwLa */ @Override public void close() { + LOG.info("ZKWatcher close started."); + zkEventProcessor.shutdown(); try { - recoverableZooKeeper.close(); + zkEventProcessor.awaitTermination(60, TimeUnit.SECONDS); } catch (InterruptedException e) { + LOG.warn("ZKWatcher event processor has not finished to terminate."); Thread.currentThread().interrupt(); } finally { - zkEventProcessor.shutdownNow(); + try { + recoverableZooKeeper.close(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } } + LOG.info("ZKWatcher close finished."); } public Configuration getConfiguration() { From c6aa731d1175244ec590bf9b87a5da17fe86d78c Mon Sep 17 00:00:00 2001 From: Victor Li Date: Thu, 13 Oct 2022 09:03:21 -0700 Subject: [PATCH 2/5] Remove unnecessary/redundant logs. --- .../main/java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java | 2 -- 1 file changed, 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 98e5fb04d043..f796f9c6a2ff 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,7 +735,6 @@ public void interruptedExceptionNoThrow(InterruptedException ie, boolean throwLa */ @Override public void close() { - LOG.info("ZKWatcher close started."); zkEventProcessor.shutdown(); try { zkEventProcessor.awaitTermination(60, TimeUnit.SECONDS); @@ -749,7 +748,6 @@ public void close() { Thread.currentThread().interrupt(); } } - LOG.info("ZKWatcher close finished."); } public Configuration getConfiguration() { From eb154bac4921401030c4f5d5bf1e836809af56bd Mon Sep 17 00:00:00 2001 From: Victor Li Date: Thu, 13 Oct 2022 09:11:33 -0700 Subject: [PATCH 3/5] Dummy change for triggering tests in hbase-server. --- hbase-server/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/hbase-server/pom.xml b/hbase-server/pom.xml index c7664209a9a0..a79270c27045 100644 --- a/hbase-server/pom.xml +++ b/hbase-server/pom.xml @@ -824,3 +824,4 @@ + From 258ee35be054f55fd40b1b19dd67a7fd38d8a51e Mon Sep 17 00:00:00 2001 From: Victor Li Date: Fri, 14 Oct 2022 12:51:47 -0700 Subject: [PATCH 4/5] Revert the dummy change. --- hbase-server/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/hbase-server/pom.xml b/hbase-server/pom.xml index a79270c27045..c7664209a9a0 100644 --- a/hbase-server/pom.xml +++ b/hbase-server/pom.xml @@ -824,4 +824,3 @@ - From 67394bd950a33a5dc9f22d308b038ee0c23b2d8c Mon Sep 17 00:00:00 2001 From: Victor Li Date: Fri, 14 Oct 2022 22:15:51 -0700 Subject: [PATCH 5/5] Reduce the wait to 15 seconds and add a force shutdown if the wait times out. --- .../java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java | 6 ++++-- 1 file changed, 4 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 f796f9c6a2ff..f499d0f9487f 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 @@ -737,9 +737,11 @@ public void interruptedExceptionNoThrow(InterruptedException ie, boolean throwLa public void close() { zkEventProcessor.shutdown(); try { - zkEventProcessor.awaitTermination(60, TimeUnit.SECONDS); + if (!zkEventProcessor.awaitTermination(15, TimeUnit.SECONDS)) { + LOG.warn("ZKWatcher event processor has not finished to terminate."); + zkEventProcessor.shutdownNow(); + } } catch (InterruptedException e) { - LOG.warn("ZKWatcher event processor has not finished to terminate."); Thread.currentThread().interrupt(); } finally { try {