Jackie-Jiang commented on code in PR #15681:
URL: https://github.com/apache/pinot/pull/15681#discussion_r2069274941


##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/relocation/SegmentRelocator.java:
##########
@@ -120,17 +121,23 @@ public SegmentRelocator(PinotHelixResourceManager 
pinotHelixResourceManager,
           LOGGER.warn("Got interrupted while rebalancing tables sequentially", 
e);
         }
       });
+      _tablesUndergoingRebalance = null;
     } else {
       _waitingTables = null;
       _waitingQueue = null;
+      _tablesUndergoingRebalance = ConcurrentHashMap.newKeySet();
     }
   }
 
   @Override
   protected void processTable(String tableNameWithType) {
     if (_waitingTables == null) {
-      LOGGER.debug("Rebalance table: {} immediately", tableNameWithType);
-      _executorService.submit(() -> rebalanceTable(tableNameWithType));
+      if (_tablesUndergoingRebalance == null || 
!_tablesUndergoingRebalance.contains(tableNameWithType)) {

Review Comment:
   (nit) The `null` check is not needed



##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/relocation/SegmentRelocator.java:
##########
@@ -196,6 +203,10 @@ private void rebalanceTable(String tableNameWithType) {
     rebalanceConfig.setMinimizeDataMovement(_minimizeDataMovement);
 
     try {
+      if (_tablesUndergoingRebalance != null) {
+        LOGGER.debug("Start rebalancing table: {}, adding to 
tablesUndergoingRebalance", tableNameWithType);
+        _tablesUndergoingRebalance.add(tableNameWithType);

Review Comment:
   We can check if the table is successfully added. By the time the thread 
reaches here, there might be another thread running on the same table



-- 
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...@pinot.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to