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 383c8027ab Fixes lock check for prune exclude actions (#6077)
383c8027ab is described below

commit 383c8027ab210004adf344964ae4b2ed841fdb16
Author: Daniel Roberts <[email protected]>
AuthorDate: Fri Feb 27 23:34:52 2026 -0500

    Fixes lock check for prune exclude actions (#6077)
    
    * Fixes lock check for prune exclude actions
    
    Correctly checks the lock format so that exclude options for the prune
    command work correctly.
    
    * Moved GCLock removal to ServiceLock
    
    * Use ServerServices instead of parsing lock data
    
    * rename method
---
 .../apache/accumulo/core/fate/zookeeper/ServiceLock.java | 16 ++++++++++++++++
 .../java/org/apache/accumulo/server/util/ZooZap.java     |  6 ++++--
 2 files changed, 20 insertions(+), 2 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 989dd718c6..b0645ea8a2 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
@@ -32,6 +32,7 @@ import 
org.apache.accumulo.core.fate.zookeeper.ZooCache.ZcStat;
 import org.apache.accumulo.core.fate.zookeeper.ZooUtil.LockID;
 import org.apache.accumulo.core.fate.zookeeper.ZooUtil.NodeMissingPolicy;
 import org.apache.accumulo.core.util.HostAndPort;
+import org.apache.accumulo.core.util.ServerServices;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.KeeperException.Code;
@@ -821,6 +822,21 @@ 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 {
+    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);
+        }
+      }
+    }
+  }
+
   /**
    * 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
diff --git 
a/server/base/src/main/java/org/apache/accumulo/server/util/ZooZap.java 
b/server/base/src/main/java/org/apache/accumulo/server/util/ZooZap.java
index 6954ba11bb..2869e8e2c2 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/ZooZap.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/ZooZap.java
@@ -39,6 +39,7 @@ import 
org.apache.accumulo.core.fate.zookeeper.ZooUtil.NodeMissingPolicy;
 import org.apache.accumulo.core.singletons.SingletonManager;
 import org.apache.accumulo.core.singletons.SingletonManager.Mode;
 import org.apache.accumulo.core.util.HostAndPort;
+import org.apache.accumulo.core.util.ServerServices;
 import org.apache.accumulo.core.volume.VolumeConfiguration;
 import org.apache.accumulo.server.fs.VolumeManager;
 import org.apache.accumulo.server.security.SecurityUtil;
@@ -178,9 +179,10 @@ public class ZooZap implements KeywordExecutable {
     if (opts.zapGc) {
       String gcLockPath = Constants.ZROOT + "/" + iid + Constants.ZGC_LOCK;
       try {
-        removeSingletonLock(zoo, gcLockPath, hostPortPredicate, opts);
+        ServiceLock.deleteLock(zoo, gcLockPath, 
ServerServices.Service.GC_CLIENT, hostPortPredicate,
+            m -> message(m, opts), opts.dryRun);
       } catch (KeeperException | InterruptedException e) {
-        log.error("Error deleting manager lock", e);
+        log.error("Error deleting gc lock", e);
       }
     }
 

Reply via email to