Skip to content

Commit

Permalink
Merge branch '3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
dlmarion committed Jan 29, 2025
2 parents aa1f30a + d6900d8 commit b900be0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 29 deletions.
28 changes: 0 additions & 28 deletions core/src/main/java/org/apache/accumulo/core/lock/ServiceLock.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.apache.accumulo.core.lock;

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

Expand Down Expand Up @@ -745,33 +744,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 IllegalStateException("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 @@ -144,7 +144,9 @@ public void zap(SiteConfiguration siteConf, String... args) {
zrw.recursiveDelete(tserverPath.toString(), NodeMissingPolicy.SKIP);
} else {
if (!zrw.getChildren(tserverPath.toString()).isEmpty()) {
if (!ServiceLock.deleteLock(zrw, tserverPath, "tserver")) {
try {
ServiceLock.deleteLock(zrw, tserverPath);
} catch (RuntimeException e) {
message("Did not delete " + tserverPath, opts);
}
}
Expand Down

0 comments on commit b900be0

Please sign in to comment.