Browse Source

ZOOKEEPER-4710 Fix ZkUtil deleteInBatch() by releasing semaphore after set flag (#2020)

Yan Zhao 1 year ago
parent
commit
77c1e4c872
1 changed files with 1 additions and 1 deletions
  1. 1 1
      zookeeper-server/src/main/java/org/apache/zookeeper/ZKUtil.java

+ 1 - 1
zookeeper-server/src/main/java/org/apache/zookeeper/ZKUtil.java

@@ -109,10 +109,10 @@ public class ZKUtil {
         List<Op> ops = new ArrayList<>();
         BatchedDeleteCbContext context = new BatchedDeleteCbContext(rateLimit);
         MultiCallback cb = (rc, path, ctx, opResults) -> {
-            ((BatchedDeleteCbContext) ctx).sem.release();
             if (rc != Code.OK.intValue()) {
                 ((BatchedDeleteCbContext) ctx).success.set(false);
             }
+            ((BatchedDeleteCbContext) ctx).sem.release();
         };
 
         // Delete the leaves first and eventually get rid of the root