Radiancebobo commented on code in PR #4873:
URL: https://github.com/apache/bookkeeper/pull/4873#discussion_r4754220117


##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorTask.java:
##########
@@ -88,24 +88,47 @@ protected CompletableFuture<?> 
publishSuspectedLedgersAsync(Collection<String> m
                 .attr("ledgers", ledgers)
                 .attr("missingBookies", missingBookies)
                 .log("Following ledgers are identified as underreplicated");
-        
auditorStats.getNumUnderReplicatedLedger().registerSuccessfulValue(ledgers.size());
+        LongAdder publishedLedgers = new LongAdder();
         LongAdder underReplicatedSize = new LongAdder();
-        FutureUtils.processList(
+        CompletableFuture<List<Void>> publishFuture = FutureUtils.processList(
                 Lists.newArrayList(ledgers),
-                ledgerId ->
-                        
ledgerManager.readLedgerMetadata(ledgerId).whenComplete((metadata, exception) 
-> {
-                            if (exception == null) {
-                                
underReplicatedSize.add(metadata.getValue().getLength());
-                            }
-                        }), null).whenComplete((res, e) -> {
+                ledgerId -> 
ledgerManager.readLedgerMetadata(ledgerId).handle((metadata, exception) -> {
+                    if (exception != null) {
+                        if (BKException.getExceptionCode(exception)
+                                == 
BKException.Code.NoSuchLedgerExistsOnMetadataServerException) {
+                            log.info()
+                                    .attr("ledgerId", ledgerId)
+                                    .log("Ledger was deleted before publishing 
underreplicated mark");
+                            return FutureUtils.Void();
+                        }
+                        log.warn()
+                                .attr("ledgerId", ledgerId)
+                                .exception(exception)
+                                .log("Unable to read ledger metadata; 
publishing underreplicated mark fail-open");
+                    } else if (metadata == null || metadata.getValue() == 
null) {
+                        log.warn()
+                                .attr("ledgerId", ledgerId)
+                                .log("Ledger metadata was empty; publishing 
underreplicated mark fail-open");
+                    } else if (metadata.getValue().getWriteQuorumSize() == 1) {
+                        auditorStats.getNumSingleReplicaLedgersSkipped().inc();

Review Comment:
   Agreed. The help text could be read as a distinct-ledger count. The intended 
semantics are cumulative skip events. I clarified the metric help and user 
docs, including repeated counts within the same audit and across later 
attempts, and added a regression test confirming one ledger under two failed 
bookies yields two skip events. The per-bookie publication flow is unchanged.



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