Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix][standalone] correctly delete bookie registration znode #23497

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -297,22 +297,16 @@ private void runBookies(ServerConfiguration baseConf) throws Exception {
}

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";

Expand All @@ -327,6 +321,16 @@ private void runBookies(ServerConfiguration baseConf) throws Exception {
}
}

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";
Expand Down
Loading