shustsud commented on a change in pull request #2813:
URL: https://github.com/apache/bookkeeper/pull/2813#discussion_r725780974



##########
File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/ScanAndCompareGarbageCollector.java
##########
@@ -231,11 +231,19 @@ public void gc(GarbageCleaner garbageCleaner) {
 
     private Set<Long> removeOverReplicatedledgers(Set<Long> bkActiveledgers, 
final GarbageCleaner garbageCleaner)
             throws InterruptedException, KeeperException {
+        // Check ledger ensembles before creating lock nodes.
+        // This is to reduce the number of lock node creations and deletions 
in ZK.
+        // The ensemble check is done again after the lock node is created.
+        final Set<Long> candidateOverReplicatedLedgers = 
preCheckOverReplicatedLedgers(bkActiveledgers);
+        if (candidateOverReplicatedLedgers.isEmpty()) {
+            return candidateOverReplicatedLedgers;
+        }
+
         final List<ACL> zkAcls = ZkUtils.getACLs(conf);
         final Set<Long> overReplicatedLedgers = Sets.newHashSet();
         final Semaphore semaphore = new Semaphore(MAX_CONCURRENT_ZK_REQUESTS);
-        final CountDownLatch latch = new 
CountDownLatch(bkActiveledgers.size());
-        for (final Long ledgerId : bkActiveledgers) {
+        final CountDownLatch latch = new 
CountDownLatch(candidateOverReplicatedLedgers.size());
+        for (final Long ledgerId : candidateOverReplicatedLedgers) {
             try {
                 // check if the ledger is being replicated already by the 
replication worker
                 if 
(ZkLedgerUnderreplicationManager.isLedgerBeingReplicated(zk, zkLedgersRootPath, 
ledgerId)) {

Review comment:
       I fixed it as above.
   
   However, I fixed it to check ledger ensembles first.
   This is to reduce the number of lock node existence checks(ZK requests) in 
Bookies that are not down.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to