From ae7623f4bbec63c4dab9ee666e43d4ea5894b40c Mon Sep 17 00:00:00 2001 From: udev Date: Tue, 27 May 2025 18:46:14 +0530 Subject: [PATCH] fix: do division first while calculating partitions (#6931) We see an overflow when we multiply the query duration to a large storage size, to fix it we divide the storage size first with the data retention time --- src/service/search/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/service/search/mod.rs b/src/service/search/mod.rs index 9e85fbd0ba..8b6a9538be 100644 --- a/src/service/search/mod.rs +++ b/src/service/search/mod.rs @@ -697,8 +697,8 @@ pub async fn search_partition( log::warn!("Data retention is zero, setting to 1 to prevent division by zero"); data_retention = 1; } - let records = (stats.doc_num as i64 * query_duration) / data_retention; - let original_size = (stats.storage_size as i64 * query_duration) / data_retention; + let records = (stats.doc_num as i64 / data_retention) * query_duration; + let original_size = (stats.storage_size as i64 / data_retention) * query_duration; log::info!( "[trace_id {trace_id}] using approximation: stream: {}, records: {}, original_size: {}", stream_name,