From c7a55b32d94794870a34bfd93d56200842e313b4 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Thu, 23 Feb 2023 12:01:58 -0600 Subject: [PATCH] Fix integer math bug in HeapUsageTracker (#6455) (#6460) * Fix a bug in Search Backpressure --------- (cherry picked from commit d4392447e6a60b312108b86aa4910213d2281889) Signed-off-by: PritLadani Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] --- .../search/backpressure/trackers/HeapUsageTracker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/opensearch/search/backpressure/trackers/HeapUsageTracker.java b/server/src/main/java/org/opensearch/search/backpressure/trackers/HeapUsageTracker.java index d6a38c8797174..bfc738351caf4 100644 --- a/server/src/main/java/org/opensearch/search/backpressure/trackers/HeapUsageTracker.java +++ b/server/src/main/java/org/opensearch/search/backpressure/trackers/HeapUsageTracker.java @@ -107,7 +107,7 @@ public static boolean isHeapTrackingSupported() { */ public static boolean isHeapUsageDominatedBySearch(List cancellableTasks, double heapPercentThreshold) { long usage = cancellableTasks.stream().mapToLong(task -> task.getTotalResourceStats().getMemoryInBytes()).sum(); - long threshold = (long) heapPercentThreshold * HEAP_SIZE_BYTES; + long threshold = (long) (heapPercentThreshold * HEAP_SIZE_BYTES); if (isHeapTrackingSupported() && usage < threshold) { logger.debug("heap usage not dominated by search requests [{}/{}]", usage, threshold); return false;