You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(query-engine): SimpleEngine truncates seconds to milliseconds; use one rounding conversion #939
SimpleEngine converts query times from seconds to milliseconds by truncating:
asap-query-engine/src/engines/simple_engine/mod.rs:553, convert_query_time_to_data_time: (query_time * 1000.0) as u64
asap-query-engine/src/engines/simple_engine/promql.rs:614: let step_ms = (step * 1000.0) as u64;
Floating-point error makes some millisecond-aligned times land just below the integer: e.g. 1095211880.820 * 1000.0 == 1095211880819.9998, which truncates to ...819. About 0.6% of millisecond-aligned query times are evaluated 1 ms early, and a range step can lose 1 ms the same way.
Two other call sites already round, each in its own way: simple_engine/sql.rs:255 and :508 ((… * 1000.0).round() as u64).
Proposal
Use one function for every protocol-seconds → milliseconds conversion: engine_api::secs_to_ms, which rounds to the nearest millisecond, and ms_to_secs for the other direction. Both are added in #937. Replace the four sites above with it (with a cast to u64 where the caller needs one), and add a regression test with 1095211880.820.
Found while reviewing #937. The new QueryEngine takes milliseconds directly from QueryRequest, so this only affects the old engine path until it is deleted.
Activity