lhotari commented on code in PR #25067:
URL: https://github.com/apache/pulsar/pull/25067#discussion_r2611605212


##########
pulsar-broker-common/src/main/java/org/apache/pulsar/bookie/rackawareness/BookieRackAffinityMapping.java:
##########
@@ -169,6 +170,13 @@ private void watchAvailableBookies() {
         }
     }
 
+    private synchronized Void processRackUpdate(BookiesRackConfiguration 
racks) {
+        updateRacksWithHost(racks);
+        // Notify ensemble placement policy after rack info is updated to 
ensure consistent state.
+        rackChangeListenerCallback(new ArrayList<>(bookieAddressListLastTime));
+        return null;
+    }

Review Comment:
   In the past, reducing the synchronization scope has helped address 
deadlocks. In this case, it would be possible to reduce the scope this way:
   
   ```suggestion
       private Void processRackUpdate(BookiesRackConfiguration racks) {
           ArrayList<BookieId> bookieIdSet;
           synchronized (this) {
               updateRacksWithHost(racks);
               bookieIdSet = new ArrayList<>(bookieAddressListLastTime);
           }
           // Notify ensemble placement policy after rack info is updated to 
ensure consistent state.
           rackChangeListenerCallback(bookieIdSet);
           return null;
       }
   ```



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