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());