This is an automated email from the ASF dual-hosted git repository.
zixuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new ebb3cb5384d [fix][standalone] correctly delete bookie registration
znode (#23497)
ebb3cb5384d is described below
commit ebb3cb5384d188b3c9d6b3fe89c2f66254103bf7
Author: Zixuan Liu <[email protected]>
AuthorDate: Fri Oct 25 11:24:57 2024 +0800
[fix][standalone] correctly delete bookie registration znode (#23497)
Signed-off-by: Zixuan Liu <[email protected]>
---
.../pulsar/zookeeper/LocalBookkeeperEnsemble.java | 26 +++++++++++++---------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git
a/pulsar-broker/src/main/java/org/apache/pulsar/zookeeper/LocalBookkeeperEnsemble.java
b/pulsar-broker/src/main/java/org/apache/pulsar/zookeeper/LocalBookkeeperEnsemble.java
index de3077959a4..939998f6f80 100644
---
a/pulsar-broker/src/main/java/org/apache/pulsar/zookeeper/LocalBookkeeperEnsemble.java
+++
b/pulsar-broker/src/main/java/org/apache/pulsar/zookeeper/LocalBookkeeperEnsemble.java
@@ -297,22 +297,16 @@ public class LocalBookkeeperEnsemble {
}
int bookiePort = portManager.get();
-
+ String bookieId = "bk" + i + "test";
// Ensure registration Z-nodes are cleared when standalone service
is restarted ungracefully
- String registrationZnode =
String.format("/ledgers/available/%s:%d",
- baseConf.getAdvertisedAddress(), bookiePort);
- if (zkc.exists(registrationZnode, null) != null) {
- try {
- zkc.delete(registrationZnode, -1);
- } catch (NoNodeException nne) {
- // Ignore if z-node was just expired
- }
- }
+ deleteBookieRegistrationZnode(
+ String.format("/ledgers/available/%s:%d",
baseConf.getAdvertisedAddress(), bookiePort));
+
deleteBookieRegistrationZnode(String.format("/ledgers/available/%s", bookieId));
bsConfs[i] = new ServerConfiguration(baseConf);
// override settings
bsConfs[i].setBookiePort(bookiePort);
- bsConfs[i].setBookieId("bk" + i + "test");
+ bsConfs[i].setBookieId(bookieId);
String zkServers = "127.0.0.1:" + zkPort;
String metadataServiceUriStr = "zk://" + zkServers + "/ledgers";
@@ -327,6 +321,16 @@ public class LocalBookkeeperEnsemble {
}
}
+ private void deleteBookieRegistrationZnode(String registrationZnode)
throws InterruptedException, KeeperException {
+ if (zkc.exists(registrationZnode, null) != null) {
+ try {
+ zkc.delete(registrationZnode, -1);
+ } catch (NoNodeException nne) {
+ // Ignore if z-node was just expired
+ }
+ }
+ }
+
public void runStreamStorage(CompositeConfiguration conf) throws Exception
{
String zkServers = "127.0.0.1:" + zkPort;
String metadataServiceUriStr = "zk://" + zkServers + "/ledgers";