hangc0276 commented on code in PR #4822:
URL: https://github.com/apache/bookkeeper/pull/4822#discussion_r4760266264


##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorReplicasCheckTask.java:
##########
@@ -171,6 +171,12 @@ void replicasCheck() throws 
ReplicationException.BKAuditException {
                 new ConcurrentHashMap<Long, MissingEntriesInfoOfLedger>();
         LedgerManager.LedgerRangeIterator ledgerRangeIterator = 
ledgerManager.getLedgerRanges(zkOpTimeoutMs);
         final Semaphore maxConcurrentSemaphore = new 
Semaphore(MAX_CONCURRENT_REPLICAS_CHECK_LEDGER_REQUESTS);
+        // These counters back the gauges published once for the whole run, so 
they must accumulate
+        // across all ledger ranges. Reset them here, not per-range, otherwise 
a later range wipes
+        // the findings of earlier ranges.
+        numLedgersFoundHavingNoReplicaOfAnEntry.set(0);

Review Comment:
   This reset is also what fixes a second symptom the description doesn't 
mention. In the old code a run that sees no ledger ranges at all (for example, 
all ledgers were deleted) never reached the per-range reset, so the previous 
run's counter values were published again as the new gauges. I checked this 
with a two-run test: run 1 has an unhealthy ledger, run 2 returns an empty 
range iterator. The old code publishes 1 on run 2, and this PR publishes 0.
   
   One suggestion: since the gauge values change for clusters with more than 
one ledger range (they now count all ranges instead of just the last), a 
release-note line would help anyone whose alerts were tuned to the old numbers.



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