HBASE-27160 ClientZKSyncer.deleteDataForClientZkUntilSuccess should break from the loop when deletion is succeeded (#4579)

Signed-off-by: Bryan Beaudreault <bbeaudreault@apache.org>
This commit is contained in:
Duo Zhang 2022-06-26 15:22:25 +08:00 committed by GitHub
parent 42853aae57
commit d7f6861e8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 9 deletions

View File

@ -196,12 +196,16 @@ public abstract class ClientZKSyncer extends ZKListener {
LOG.debug("Delete remote " + node + ", client zk wather: " + clientZkWatcher); LOG.debug("Delete remote " + node + ", client zk wather: " + clientZkWatcher);
try { try {
ZKUtil.deleteNode(clientZkWatcher, node); ZKUtil.deleteNode(clientZkWatcher, node);
break;
} catch (KeeperException e) { } 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); LOG.debug("Failed to delete node from client ZK, will retry later", e);
if (e.code() == KeeperException.Code.SESSIONEXPIRED) { if (e.code() == KeeperException.Code.SESSIONEXPIRED) {
reconnectAfterExpiration(); reconnectAfterExpiration();
} }
} }
} }
} }

View File

@ -133,15 +133,10 @@ public class TestSeparateClientZKCluster {
HMaster master = cluster.getMaster(); HMaster master = cluster.getMaster();
master.stopMaster(); master.stopMaster();
LOG.info("Stopped master {}", master.getServerName()); LOG.info("Stopped master {}", master.getServerName());
while (master.isAlive()) { TEST_UTIL.waitFor(30000, () -> !master.isAlive());
Thread.sleep(200);
}
LOG.info("Shutdown master {}", master.getServerName()); LOG.info("Shutdown master {}", master.getServerName());
while (cluster.getMaster() == null || !cluster.getMaster().isInitialized()) { TEST_UTIL.waitFor(30000,
LOG.info("Get master {}", () -> cluster.getMaster() != null && cluster.getMaster().isInitialized());
cluster.getMaster() == null ? "null" : cluster.getMaster().getServerName());
Thread.sleep(200);
}
LOG.info("Got master {}", cluster.getMaster().getServerName()); LOG.info("Got master {}", cluster.getMaster().getServerName());
// confirm client access still works // confirm client access still works
assertTrue(admin.balance(BalanceRequest.defaultInstance()).isBalancerRan()); assertTrue(admin.balance(BalanceRequest.defaultInstance()).isBalancerRan());