codelipenghui commented on code in PR #4926:
URL: https://github.com/apache/bookkeeper/pull/4926#discussion_r4460163893


##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java:
##########
@@ -619,7 +619,10 @@ private void watchBookieChanges() throws BKException {
      */
     public void shutdown() {
         log.info("Shutting down auditor");
-        executor.shutdown();
+        // Interrupt the running audit rather than wait for it: an audit can 
wait for the ledger
+        // replication to be enabled for as long as it stays disabled, and 
shutdown() would still
+        // run the audit delayed for a lost bookie. The next auditor runs the 
audits again.
+        executor.shutdownNow();

Review Comment:
   **[P2] Make the full-ledger check's private-client cleanup 
interruption-safe**
   
   If shutdown interrupts an active `checkAllLedgers()` while it waits for 
`processFuture`, 
[FutureUtils.result](<https://github.com/apache/bookkeeper/blob/19799361ed9d9ca373f98e25c3e636dc2a26f406/bookkeeper-common/src/main/java/org/apache/bookkeeper/common/concurrent/FutureUtils.java#L80-L87>)
 restores the interrupt flag before throwing. The check then enters its 
[finally 
block](<https://github.com/apache/bookkeeper/blob/19799361ed9d9ca373f98e25c3e636dc2a26f406/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorCheckAllLedgersTask.java#L238-L249>)
 and calls `localClient.close()` on that interrupted thread.
   
   
[BookKeeper.close()](<https://github.com/apache/bookkeeper/blob/19799361ed9d9ca373f98e25c3e636dc2a26f406/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeper.java#L1527-L1594>)
 sets `closed = true` before its interruptible termination waits. If the 
scheduler has not yet terminated, the wait throws and skips cleanup of the 
remaining pools, timer, event-loop group and metadata driver. This per-check 
client is not the auditor's main client, so the outer shutdown does not reclaim 
those resources; another `close()` would return because it is already marked 
closed.
   
   This weakness existed after the old forced interruption, but immediate 
interruption now exposes short audits that previously finished and cleaned up 
within the 30-second grace period. Please ensure cancellation cannot abandon 
the private client's cleanup, preserving/restoring interruption appropriately, 
and add a latch-controlled shutdown-during-full-ledger-check test that verifies 
its resources actually terminate. This is a source-traced issue, not a locally 
reproduced leak.



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