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


##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java:
##########
@@ -2175,14 +2175,27 @@ void handleBookieFailure(final Map<Integer, BookieId> 
failedBookies) {
             if (changingEnsemble) {
                 delayedWriteFailedBookies.putAll(failedBookies);
             } else {
-                changingEnsemble = true;
-                triggerLoop = true;
-
                 toReplace = new HashMap<>(delayedWriteFailedBookies);
                 delayedWriteFailedBookies.clear();
                 toReplace.putAll(failedBookies);
 
                 origEnsemble = getCurrentEnsemble();
+
+                for (Map.Entry<Integer, BookieId> entry : 
toReplace.entrySet()) {
+                    Integer bookieIndex = entry.getKey();
+                    BookieId addr = entry.getValue();
+                    if (origEnsemble.get(bookieIndex).equals(addr)) {
+                        changingEnsemble = true;

Review Comment:
   We need to set `changingEnsemble = true` when entering the else code block 
to avoid a potential race condition. If all the bookies in the toReplace set do 
not exist in the current ensemble, set changingEnsemble back to false.
   
   What's more, please add a comment to explain why we need this logic. thanks.



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