This is an automated email from the ASF dual-hosted git repository.
ddanielr pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/2.1 by this push:
new b9cdb060af Fix gc lock removals (#6166)
b9cdb060af is described below
commit b9cdb060af8996292903eede89317dd777d0db47
Author: Daniel Roberts <[email protected]>
AuthorDate: Wed Mar 4 17:15:10 2026 -0500
Fix gc lock removals (#6166)
* Fix gc lock removals
Does not delete the top level `gc/lock/` path, instead it just deletes
all locks underneath the path.
Updates ITs and the Admin utility to delete gc locks the same way.
* Improvements to Admin stop command
Switches to using ServiceLock.deleteLocks for tserver locks so lock
deletes can show up in the Admin log (if debug is enabled).
Fixed a bug where the command would fail if no scan servers were running.
Added the ability to also force stop the compaction-coordinator server
---
.../accumulo/core/fate/zookeeper/ServiceLock.java | 13 ++++++++++---
.../java/org/apache/accumulo/server/util/Admin.java | 17 +++++++++++++----
.../accumulo/test/functional/GarbageCollectorIT.java | 4 ++--
.../accumulo/test/upgrade/GCUpgrade9to10TestIT.java | 6 ++++--
4 files changed, 29 insertions(+), 11 deletions(-)
diff --git
a/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ServiceLock.java
b/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ServiceLock.java
index b0645ea8a2..0d433d55c2 100644
---
a/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ServiceLock.java
+++
b/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ServiceLock.java
@@ -825,13 +825,20 @@ public class ServiceLock implements Watcher {
public static void deleteLock(ZooReaderWriter zoo, String path,
ServerServices.Service serviceType, Predicate<HostAndPort>
hostPortPredicate,
Consumer<String> messageOutput, Boolean dryRun) throws KeeperException,
InterruptedException {
+
+ Objects.requireNonNull(path, "Lock path cannot be null");
+ Objects.requireNonNull(hostPortPredicate, "host predicate cannot be null");
+
var lockData = ServiceLock.getLockData(zoo.getZooKeeper(),
ServiceLock.path(path));
if (lockData != null) {
ServerServices lock = new ServerServices(new String(lockData, UTF_8));
if (hostPortPredicate.test(lock.getAddress(serviceType))) {
- messageOutput.accept("Deleting " + path + " from zookeeper");
- if (!dryRun) {
- zoo.recursiveDelete(path, NodeMissingPolicy.SKIP);
+ List<String> children = zoo.getChildren(path);
+ for (String child : children) {
+ messageOutput.accept("Deleting " + path + "/" + child + " from
zookeeper");
+ if (!dryRun) {
+ zoo.recursiveDelete(path + "/" + child, NodeMissingPolicy.SKIP);
+ }
}
}
}
diff --git
a/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java
b/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java
index b081922e6f..8251333ee2 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/Admin.java
@@ -75,6 +75,7 @@ import
org.apache.accumulo.core.singletons.SingletonManager.Mode;
import org.apache.accumulo.core.trace.TraceUtil;
import org.apache.accumulo.core.util.AddressUtil;
import org.apache.accumulo.core.util.HostAndPort;
+import org.apache.accumulo.core.util.ServerServices;
import org.apache.accumulo.core.util.tables.TableMap;
import org.apache.accumulo.server.ServerContext;
import org.apache.accumulo.server.cli.ServerUtilOpts;
@@ -589,20 +590,28 @@ public class Admin implements KeywordExecutable {
var iid = context.getInstanceID();
String tserversPath = Constants.ZROOT + "/" + iid +
Constants.ZTSERVERS;
- ZooZap.removeLocks(zk, tserversPath, hostAndPort::contains, opts);
+ ServiceLock.deleteLocks(zk, tserversPath, hostAndPort::contains,
log::debug, false);
String compactorsBasepath = Constants.ZROOT + "/" + iid +
Constants.ZCOMPACTORS;
ZooZap.removeCompactorGroupedLocks(zk, compactorsBasepath, rg -> true,
hostAndPort::contains, opts);
String sserversPath = Constants.ZROOT + "/" + iid +
Constants.ZSSERVERS;
- ZooZap.removeScanServerGroupLocks(zk, sserversPath,
hostAndPort::contains, rg -> true,
- opts);
+ try {
+ ZooZap.removeScanServerGroupLocks(zk, sserversPath,
hostAndPort::contains, rg -> true,
+ opts);
+ } catch (IllegalStateException e) {
+ log.debug("No Scan Server locks currently exist", e);
+ }
String managerLockPath = Constants.ZROOT + "/" + iid +
Constants.ZMANAGER_LOCK;
ZooZap.removeSingletonLock(zk, managerLockPath, hostAndPort::contains,
opts);
String gcLockPath = Constants.ZROOT + "/" + iid + Constants.ZGC_LOCK;
- ZooZap.removeSingletonLock(zk, gcLockPath, hostAndPort::contains,
opts);
+ ServiceLock.deleteLock(zk, gcLockPath,
ServerServices.Service.GC_CLIENT,
+ hostAndPort::contains, log::debug, opts.dryRun);
String monitorLockPath = Constants.ZROOT + "/" + iid +
Constants.ZMONITOR_LOCK;
ZooZap.removeSingletonLock(zk, monitorLockPath, hostAndPort::contains,
opts);
+ String compactionCoordinatorLockPath =
+ Constants.ZROOT + "/" + iid + Constants.ZCOORDINATOR_LOCK;
+ ZooZap.removeSingletonLock(zk, compactionCoordinatorLockPath,
hostAndPort::contains, opts);
} else {
for (var server : hostAndPort) {
signalGracefulShutdown(context, server);
diff --git
a/test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java
b/test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java
index 25e89fbd60..343eade354 100644
---
a/test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java
+++
b/test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java
@@ -118,10 +118,10 @@ public class GarbageCollectorIT extends
ConfigurableMacBase {
getCluster().killProcess(ServerType.GARBAGE_COLLECTOR,
getCluster().getProcesses().get(ServerType.GARBAGE_COLLECTOR).iterator().next());
// delete lock in zookeeper if there, this will allow next GC to start
quickly
- var path = ServiceLock.path(getServerContext().getZooKeeperRoot() +
Constants.ZGC_LOCK);
+ String path = getServerContext().getZooKeeperRoot() + Constants.ZGC_LOCK;
ZooReaderWriter zk = getServerContext().getZooReaderWriter();
try {
- ServiceLock.deleteLock(zk, path);
+ ServiceLock.deleteLock(zk, path, Service.GC_CLIENT, hostAndPort -> true,
log::debug, false);
} catch (IllegalStateException e) {
log.error("Unable to delete ZooLock for mini accumulo-gc", e);
}
diff --git
a/test/src/main/java/org/apache/accumulo/test/upgrade/GCUpgrade9to10TestIT.java
b/test/src/main/java/org/apache/accumulo/test/upgrade/GCUpgrade9to10TestIT.java
index 897750022e..15cfbd1ace 100644
---
a/test/src/main/java/org/apache/accumulo/test/upgrade/GCUpgrade9to10TestIT.java
+++
b/test/src/main/java/org/apache/accumulo/test/upgrade/GCUpgrade9to10TestIT.java
@@ -46,6 +46,7 @@ import org.apache.accumulo.core.metadata.schema.Ample;
import org.apache.accumulo.core.metadata.schema.MetadataSchema.DeletesSection;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.core.security.TablePermission;
+import org.apache.accumulo.core.util.ServerServices;
import org.apache.accumulo.manager.upgrade.Upgrader9to10;
import org.apache.accumulo.minicluster.ServerType;
import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl;
@@ -84,10 +85,11 @@ public class GCUpgrade9to10TestIT extends
ConfigurableMacBase {
getCluster().killProcess(ServerType.GARBAGE_COLLECTOR,
getCluster().getProcesses().get(ServerType.GARBAGE_COLLECTOR).iterator().next());
// delete lock in zookeeper if there, this will allow next GC to start
quickly
- var path = ServiceLock.path(getServerContext().getZooKeeperRoot() +
Constants.ZGC_LOCK);
+ String path = getServerContext().getZooKeeperRoot() + Constants.ZGC_LOCK;
ZooReaderWriter zk = getServerContext().getZooReaderWriter();
try {
- ServiceLock.deleteLock(zk, path);
+ ServiceLock.deleteLock(zk, path, ServerServices.Service.GC_CLIENT,
hostAndPort -> true,
+ log::debug, false);
} catch (IllegalStateException e) {
log.error("Unable to delete ZooLock for mini accumulo-gc", e);
}