You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2021/10/06 07:04:34 UTC
[GitHub] [bookkeeper] nicoloboschi commented on a change in pull request #2813: Add pre-check to over-replicated ledger GC
nicoloboschi commented on a change in pull request #2813:
URL: https://github.com/apache/bookkeeper/pull/2813#discussion_r722943183
##########
File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/ScanAndCompareGarbageCollector.java
##########
@@ -291,4 +288,55 @@ public void gc(GarbageCleaner garbageCleaner) {
bkActiveledgers.removeAll(overReplicatedLedgers);
return overReplicatedLedgers;
}
+
+ private Set<Long> preCheckOverReplicatedLedgers(Set<Long> bkActiveLedgers) throws InterruptedException {
+ final Set<Long> candidateOverReplicatedLedgers = Sets.newHashSet();
+ final Semaphore semaphore = new Semaphore(MAX_CONCURRENT_ZK_REQUESTS);
+ final CountDownLatch latch = new CountDownLatch(bkActiveLedgers.size());
+
+ for (final Long ledgerId : bkActiveLedgers) {
+ try {
+ semaphore.acquire();
+ ledgerManager.readLedgerMetadata(ledgerId)
+ .whenComplete((metadata, exception) -> {
+ try {
+ if (exception == null) {
+ if (isNotBookieIncludedInLedgerEnsembles(metadata)) {
+ candidateOverReplicatedLedgers.add(ledgerId);
+ }
+ }
+ } finally {
+ semaphore.release();
+ latch.countDown();
+ }
+ });
+ } catch (Throwable t) {
+ LOG.error("Exception when iterating through the ledgers to pre-check for over-replication", t);
+ latch.countDown();
+ }
+ }
+ latch.await();
+ LOG.info("Finished pre-check over-replicated ledgers. candidateOverReplicatedLedgersSize={}",
Review comment:
Maybe it can be interesting to log how many ledgers are over replicated over the total number of active ledgers (bkActiveLedgers)
something like
`Over-replicated ledgers pre-check count: {}/{}, candidateOverReplicatedLedgers.size(), bkActiveLedgers.size()`
--
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: issues-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org