Skip to content

Commit

Permalink
Removed call to ServiceLock that checked lock data equivalence (apach…
Browse files Browse the repository at this point in the history
  • Loading branch information
dlmarion authored Jan 29, 2025
1 parent 7f8f120 commit 712e50e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.apache.accumulo.core.fate.zookeeper;

import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Objects.requireNonNull;

import java.util.ArrayList;
Expand Down Expand Up @@ -736,33 +735,6 @@ public static void deleteLock(ZooReaderWriter zk, ServiceLockPath path)

}

public static boolean deleteLock(ZooReaderWriter zk, ServiceLockPath path, String lockData)
throws InterruptedException, KeeperException {

List<String> children = validateAndSort(path, zk.getChildren(path.toString()));

if (children.isEmpty()) {
throw new IllegalStateException("No lock is held at " + path);
}

String lockNode = children.get(0);

if (!lockNode.startsWith(ZLOCK_PREFIX)) {
throw new RuntimeException("Node " + lockNode + " at " + path + " is not a lock node");
}

byte[] data = zk.getData(path + "/" + lockNode);

if (lockData.equals(new String(data, UTF_8))) {
String pathToDelete = path + "/" + lockNode;
LOG.debug("Deleting all at path {} due to lock deletion", pathToDelete);
zk.recursiveDelete(pathToDelete, NodeMissingPolicy.FAIL);
return true;
}

return false;
}

/**
* Checks that the lock still exists in ZooKeeper. The typical mechanism for determining if a lock
* is lost depends on a Watcher set on the lock node. There exists a case where the Watcher may
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ public void zap(SiteConfiguration siteConf, String... args) {
} else {
var zLockPath = ServiceLock.path(tserversPath + "/" + child);
if (!zoo.getChildren(zLockPath.toString()).isEmpty()) {
if (!ServiceLock.deleteLock(zoo, zLockPath, "tserver")) {
try {
ServiceLock.deleteLock(zoo, zLockPath);
} catch (RuntimeException e) {
message("Did not delete " + tserversPath + "/" + child, opts);
}
}
Expand Down

0 comments on commit 712e50e

Please sign in to comment.