merlimat commented on code in PR #4925:
URL: https://github.com/apache/bookkeeper/pull/4925#discussion_r4460365030


##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorElector.java:
##########
@@ -264,6 +273,26 @@ public void shutdown() throws InterruptedException {
                 log.warn().exception(e).log("Failed to close bookkeeper 
client");
             }
         }
+        if (interrupted != null) {
+            throw interrupted;
+        }
+    }
+
+    /**
+     * Close the auditor manager from another thread than the election one: on 
a bookie that is not
+     * the auditor, the election task waits in tryToBecomeAuditor() until the 
bookie becomes the
+     * auditor, and closing the manager is what ends that wait. Closing 
deletes the vote, which waits
+     * for ZooKeeper to be reachable, so it gets 10 seconds before being 
interrupted.
+     */
+    private void closeAuditorManager() throws InterruptedException {
+        Thread closer = new Thread(shutdownTask, "AuditorElector-close-" + 
bookieId);
+        closer.setDaemon(true);
+        closer.start();
+        closer.join(TimeUnit.SECONDS.toMillis(10));
+        if (closer.isAlive()) {
+            log.warn("Failed to close auditor manager in 10 seconds, 
interrupting");
+            closer.interrupt();

Review Comment:
   Fixed in a6fda44c07: when the join is interrupted, `closeAuditorManager()` 
now interrupts the closer before rethrowing, and `shutdown()` keeps its cleanup 
and still propagates the `InterruptedException`. The new 
`testInterruptedShutdownInterruptsManagerClose` blocks the manager's close, 
interrupts the shutdown caller once the close has started, and asserts that 
`shutdown()` throws `InterruptedException` and that the close is interrupted 
within 5 seconds; without the fix it fails with `TimeoutException`.
   
   _🤖 Addressed by [Claude Code](https://claude.com/claude-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