mqliang commented on code in PR #14536:
URL: https://github.com/apache/pinot/pull/14536#discussion_r1857419191


##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/SegmentStatusChecker.java:
##########
@@ -330,46 +337,58 @@ private void updateSegmentMetrics(String 
tableNameWithType, TableConfig tableCon
         }
       }
 
-      int numEVReplicas = 0;
+      int numEVOnlineReplicas = 0;
+      int numEVConsumingReplicas = 0;
       if (externalView != null) {
         Map<String, String> stateMap = externalView.getStateMap(segment);
         if (stateMap != null) {
           for (Map.Entry<String, String> entry : stateMap.entrySet()) {
             String state = entry.getValue();
-            if (state.equals(SegmentStateModel.ONLINE) || 
state.equals(SegmentStateModel.CONSUMING)) {
-              numEVReplicas++;
+            if (state.equals(SegmentStateModel.ONLINE)) {
+              numEVOnlineReplicas++;
+            }
+            if (state.equals(SegmentStateModel.CONSUMING)) {
+              numEVConsumingReplicas++;
             }
             if (state.equals(SegmentStateModel.ERROR)) {
               errorSegments.add(Pair.of(segment, entry.getKey()));
             }
           }
         }
       }
-      if (numEVReplicas == 0) {
+      if (numEVOnlineReplicas == 0 && numEVConsumingReplicas == 0) {
         offlineSegments.add(segment);
-      } else if (numEVReplicas < numISReplicas) {
+      } else if (numEVOnlineReplicas + numEVConsumingReplicas < 
numISOnlineReplicas + numISConsumingReplicas) {
         partialOnlineSegments.add(segment);
-      } else {
-        // Do not allow nReplicasEV to be larger than nReplicasIS
-        numEVReplicas = numISReplicas;
       }
-      minEVReplicas = Math.min(minEVReplicas, numEVReplicas);
-    }
 
-    if (maxISReplicas == Integer.MIN_VALUE) {
-      try {
-        maxISReplicas = Math.max(Integer.parseInt(idealState.getReplicas()), 
1);
-      } catch (NumberFormatException e) {
-        maxISReplicas = 1;
+      if (numEVConsumingReplicas == 0) { // it's a immutable segment
+        minEVImmutableReplicas = Math.min(minEVImmutableReplicas, 
numEVOnlineReplicas);

Review Comment:
   How about changing L365 as 
   ```
   if (numISConsumingReplicas == 0 && numEVConsumingReplicas == 0) { // it's a 
immutable segment
   ```
   
   This should also cover the scenario that a mutable segment just transit to a 
immutable segment:
   * `numISConsumingReplicas == 0 && numEVConsumingReplicas == 0` : it's a 
immutable segment
   * `numISConsumingReplicas != 0 || numEVConsumingReplicas != 0`:  it's a 
mutable segment



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