FrankChen021 commented on code in PR #19413:
URL: https://github.com/apache/druid/pull/19413#discussion_r3214319737


##########
server/src/main/java/org/apache/druid/server/coordinator/duty/BalanceSegments.java:
##########
@@ -60,9 +63,20 @@ public DruidCoordinatorRuntimeParams 
run(DruidCoordinatorRuntimeParams params)
       return params;
     }
 
-    params.getDruidCluster().getManagedHistoricals().forEach(
-        (tier, servers) -> new TierSegmentBalancer(tier, servers, 
maxSegmentsToMove, params).run()
-    );
+    final Set<String> coordinatingVersions = 
params.getCoordinatorDynamicConfig().getCoordinatingVersions();
+    params.getDruidCluster().getManagedHistoricals().forEach((tier, servers) 
-> {
+      if (coordinatingVersions.isEmpty()) {
+        new TierSegmentBalancer(tier, servers, maxSegmentsToMove, 
params).run();
+      } else {
+        // Partition tier servers by deployment group so segments never move 
across groups.
+        // Servers with no deploymentGroup form their own partition keyed 
under the empty string.
+        final Map<String, Set<ServerHolder>> serversByGroup = 
partitionByDeploymentGroup(servers);
+        final int perGroupMax = Math.max(1, maxSegmentsToMove / 
serversByGroup.size());

Review Comment:
   P2 Per-group balancing can exceed the configured move cap
   
   When coordinatingVersions is non-empty, maxSegmentsToMove is divided per 
deployment group but then clamped with Math.max(1, ...). If the configured cap 
is lower than the number of groups, each group can move one segment, so a tier 
with three groups and maxSegmentsToMove=1 can move up to three segments in one 
coordinator run. This violates the documented cap and can cause more segment 
movement/load pressure than operators configured. Consider distributing the cap 
so the sum across groups never exceeds maxSegmentsToMove, or skipping groups 
once the tier budget is exhausted.



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