From 9537f07ee535f42cbbd62a580d340f2bce21f1d8 Mon Sep 17 00:00:00 2001 From: Duo Zhang Date: Sun, 26 Jun 2022 15:22:25 +0800 Subject: [PATCH] HBASE-27160 ClientZKSyncer.deleteDataForClientZkUntilSuccess should break from the loop when deletion is succeeded (#4579) Signed-off-by: Bryan Beaudreault (cherry picked from commit d7f6861e8dfc06398455330e25bdac958d0dcb37) --- .../hadoop/hbase/master/zksyncer/ClientZKSyncer.java | 6 +++++- .../hbase/client/TestSeparateClientZKCluster.java | 11 +++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/zksyncer/ClientZKSyncer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/zksyncer/ClientZKSyncer.java index d85cc27dab7..a9881ef9b64 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/zksyncer/ClientZKSyncer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/zksyncer/ClientZKSyncer.java @@ -196,12 +196,16 @@ public abstract class ClientZKSyncer extends ZKListener { LOG.debug("Delete remote " + node + ", client zk wather: " + clientZkWatcher); try { ZKUtil.deleteNode(clientZkWatcher, node); + break; } catch (KeeperException e) { + if (e.code() == KeeperException.Code.NONODE) { + LOG.debug("Node is already deleted, give up", e); + break; + } LOG.debug("Failed to delete node from client ZK, will retry later", e); if (e.code() == KeeperException.Code.SESSIONEXPIRED) { reconnectAfterExpiration(); } - } } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSeparateClientZKCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSeparateClientZKCluster.java index b3a26a5ffee..813cb92ac4d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSeparateClientZKCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSeparateClientZKCluster.java @@ -133,15 +133,10 @@ public class TestSeparateClientZKCluster { HMaster master = cluster.getMaster(); master.stopMaster(); LOG.info("Stopped master {}", master.getServerName()); - while (!master.isShutDown()) { - Thread.sleep(200); - } + TEST_UTIL.waitFor(30000, () -> !master.isAlive()); LOG.info("Shutdown master {}", master.getServerName()); - while (cluster.getMaster() == null || !cluster.getMaster().isInitialized()) { - LOG.info("Get master {}", - cluster.getMaster() == null ? "null" : cluster.getMaster().getServerName()); - Thread.sleep(200); - } + TEST_UTIL.waitFor(30000, + () -> cluster.getMaster() != null && cluster.getMaster().isInitialized()); LOG.info("Got master {}", cluster.getMaster().getServerName()); // confirm client access still works assertTrue(admin.balance(BalanceRequest.defaultInstance()).isBalancerRan());