Copilot commented on code in PR #7076: URL: https://github.com/apache/hbase/pull/7076#discussion_r2153462589
########## hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HeapMemoryManager.java: ########## @@ -241,6 +224,31 @@ public float getHeapOccupancyPercent() { : this.heapOccupancyPercent; } + private boolean isHeapMemoryUsageExceedingLimit(float memStoreFraction, + float blockCacheFraction) { + // Use integer percentage to avoid subtle float precision issues and ensure consistent + // comparison. This also maintains backward compatibility with previous logic relying on int + // truncation. + int memStorePercent = (int) (memStoreFraction * CONVERT_TO_PERCENTAGE); + int blockCachePercent = (int) (blockCacheFraction * CONVERT_TO_PERCENTAGE); + int minFreeHeapPercent = (int) (this.minFreeHeapFraction * CONVERT_TO_PERCENTAGE); + + return memStorePercent + blockCachePercent + minFreeHeapPercent > CONVERT_TO_PERCENTAGE; + } + + private void checkHeapMemoryLimits(String memStoreConfKey, float memStoreFraction, + String blockCacheConfKey, float blockCacheFraction) { + if (!isHeapMemoryUsageExceedingLimit(memStoreFraction, blockCacheFraction)) { Review Comment: The negation is reversed: currently this throws when the heap usage is within limits. It should throw only when `isHeapMemoryUsageExceedingLimit(...)` returns true. ```suggestion if (isHeapMemoryUsageExceedingLimit(memStoreFraction, blockCacheFraction)) { ``` -- 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: issues-unsubscr...@hbase.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org