You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "Jackie-Jiang (via GitHub)" <gi...@apache.org> on 2023/02/28 18:38:45 UTC

[GitHub] [pinot] Jackie-Jiang commented on a diff in pull request #10348: [bugfix] Fix bug with PERCENT_SEGMENTS_AVAILABLE metric rounding down

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


##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/SegmentStatusChecker.java:
##########
@@ -298,7 +298,7 @@ private void updateSegmentMetrics(String tableNameWithType, TableConfig tableCon
         (nReplicasIdealMax > 0) ? (nReplicasExternal * 100 / nReplicasIdealMax) : 100);
     _controllerMetrics.setValueOfTableGauge(tableNameWithType, ControllerGauge.SEGMENTS_IN_ERROR_STATE, nErrors);
     _controllerMetrics.setValueOfTableGauge(tableNameWithType, ControllerGauge.PERCENT_SEGMENTS_AVAILABLE,
-        (nSegments > 0) ? (100 - (nOffline * 100 / nSegments)) : 100);
+        (nSegments > 0) ? (long) (100 - (nOffline * 100.0 / nSegments)) : 100);

Review Comment:
   Avoid introducing double to avoid the precision issue
   ```suggestion
           (nSegments > 0) ? (nSegments - nOffline) * 100 / nSegments : 100);
   ```



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

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


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