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


##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/rebalance/TableRebalancer.java:
##########
@@ -542,9 +542,19 @@ private RebalanceResult doRebalance(TableConfig 
tableConfig, RebalanceConfig reb
         if (segmentsToMoveChanged) {
           try {
             // Re-calculate the instance partitions in case the instance 
configs changed during the rebalance
-            instancePartitionsMap =
-                getInstancePartitionsMap(tableConfig, reassignInstances, 
bootstrap, false,
-                    minimizeDataMovement, tableRebalanceLogger).getLeft();
+            Pair<Map<InstancePartitionsType, InstancePartitions>, Boolean> 
instancePartitionsMapAndUnchanged =
+                getInstancePartitionsMap(tableConfig, reassignInstances, 
bootstrap, false, minimizeDataMovement,
+                    tableRebalanceLogger);
+            instancePartitionsMap = 
instancePartitionsMapAndUnchanged.getLeft();
+            instancePartitionsUnchanged = 
instancePartitionsMapAndUnchanged.getRight();
+            // If the instance partitions have changed, clear the 
segmentPartitionIdMap as the number of partitions
+            // may have changed, resulting in a different partitionId 
calculation. This change will only make a
+            // difference for the scenario when it was changed from or to 1 
partition. The numPartitions is not used
+            // otherwise.
+            if (!instancePartitionsUnchanged) {
+              LOGGER.info("Clear the cached segmentPartitionIdMap as the 
instance partitions has changed");
+              segmentPartitionIdMap.clear();
+            }

Review Comment:
   Good catch. Discussed offline and reverting this



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