somandal commented on code in PR #15317:
URL: https://github.com/apache/pinot/pull/15317#discussion_r2010970056


##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/rebalance/DefaultRebalancePreChecker.java:
##########
@@ -279,6 +299,48 @@ private RebalancePreCheckerResult 
checkDiskUtilization(Map<String, Map<String, S
         : RebalancePreCheckerResult.error(message.toString());
   }
 
+  private RebalancePreCheckerResult checkRebalanceConfig(RebalanceConfig 
rebalanceConfig, TableConfig tableConfig,
+      Map<String, Map<String, String>> currentAssignment, Map<String, 
Map<String, String>> targetAssignment) {
+    StringBuilder message = new StringBuilder();
+    boolean pass = true;
+    if (rebalanceConfig.isBestEfforts()) {
+      pass = false;
+      message.append("bestEfforts is enabled, only enable it if you know what 
you are doing\n");
+    }
+    List<String> segmentsToMove = 
SegmentAssignmentUtils.getSegmentsToMove(currentAssignment, targetAssignment);
+
+    int numReplicas = Integer.MAX_VALUE;
+    for (String segment : segmentsToMove) {
+      numReplicas = Math.min(targetAssignment.get(segment).size(), 
numReplicas);
+    }
+
+    if (rebalanceConfig.isDowntime() && !segmentsToMove.isEmpty() && 
numReplicas > 1) {
+      pass = false;
+      message.append("Number of replicas (")
+          .append(numReplicas)
+          .append(") is greater than 1, downtime is not recommended.\n");
+    }
+    if (rebalanceConfig.getMinAvailableReplicas() >= 0) {
+      // For non-negative value, use it as min available replicas
+      if (rebalanceConfig.getMinAvailableReplicas() >= numReplicas) {
+        pass = false;
+        message.append("The number of replicas (")
+            .append(numReplicas)
+            .append(") is less than minAvailableReplicas. The rebalance would 
fail.\n");
+      }
+    }

Review Comment:
   Specifically, in the `TableRebalancer`, we check this:
   ```
       if (minReplicasToKeepUpForNoDowntime >= 0) {
         // For non-negative value, use it as min available replicas
         if (minReplicasToKeepUpForNoDowntime >= numReplicas) {
           onReturnFailure(String.format(
               "For rebalanceId: %s, Illegal config for 
minReplicasToKeepUpForNoDowntime: %d for table: %s, "
                   + "must be less than number of replicas: %d, aborting the 
rebalance", rebalanceJobId,
               minReplicasToKeepUpForNoDowntime, tableNameWithType, 
numReplicas), null);
           return new RebalanceResult(rebalanceJobId, 
RebalanceResult.Status.FAILED,
               "Illegal min available replicas config", instancePartitionsMap, 
tierToInstancePartitionsMap,
               targetAssignment, preChecksResult, summaryResult);
         }
         minAvailableReplicas = minReplicasToKeepUpForNoDowntime;
       }
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to