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



##########
File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/ScanAndCompareGarbageCollector.java
##########
@@ -237,8 +237,12 @@ public void gc(GarbageCleaner garbageCleaner) {
         final CountDownLatch latch = new 
CountDownLatch(bkActiveledgers.size());
         for (final Long ledgerId : bkActiveledgers) {
             try {
-                // check if the ledger is being replicated already by the 
replication worker
-                if 
(ZkLedgerUnderreplicationManager.isLedgerBeingReplicated(zk, zkLedgersRootPath, 
ledgerId)) {
+                // 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.
+                // also, check if the ledger is being replicated already by 
the replication worker
+                if 
(!isNotBookieIncludedInLedgerEnsembles(ledgerManager.readLedgerMetadata(ledgerId).get())

Review comment:
       readLedgerMetadata is a costly operation,
   Can you please move it in a dedicated line, out of the 'if' statement?
   This way is it more evident while reading the code?




-- 
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