thetumbled commented on code in PR #22753:
URL: https://github.com/apache/pulsar/pull/22753#discussion_r1616011784


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ModularLoadManagerImpl.java:
##########
@@ -1131,11 +1161,16 @@ public void writeBundleDataOnZooKeeper() {
         // Write the bundle data to metadata store.
         List<CompletableFuture<Void>> futures = new ArrayList<>();
 
-        for (Map.Entry<String, BundleData> entry : 
loadData.getBundleData().entrySet()) {
-            final String bundle = entry.getKey();
-            final BundleData data = entry.getValue();
-            futures.add(
-                    
pulsarResources.getLoadBalanceResources().getBundleDataResources().updateBundleData(bundle,
 data));
+        // use synchronized to protect bundleArr.
+        synchronized (this) {
+            int updateBundleCount = selectTopKBundle();
+            for (int i = 0; i < updateBundleCount; i++) {
+                final Map.Entry<String, BundleData> entry = (Map.Entry<String, 
BundleData>) bundleArr.get(i);
+                final String bundle = entry.getKey();
+                final BundleData data = entry.getValue();
+                
futures.add(pulsarResources.getLoadBalanceResources().getBundleDataResources()
+                        .updateBundleData(bundle, data));

Review Comment:
   thanks for review, i push a new commit.



-- 
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: commits-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to