From 2f3a34dc6fc8754c20ce3387d5fbc8fd07f4d953 Mon Sep 17 00:00:00 2001 From: discord9 <55937128+discord9@users.noreply.github.com> Date: Wed, 21 Oct 2026 13:14:38 +0800 Subject: [PATCH] fix(promql): skip accounting ledger for unbudgeted vector merges Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> --- src/promql/src/vector_match.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/promql/src/vector_match.rs b/src/promql/src/vector_match.rs index a4a7a5f2269..8f4e49ab250 100644 --- a/src/promql/src/vector_match.rs +++ b/src/promql/src/vector_match.rs @@ -1154,8 +1154,13 @@ fn merge_fields( builder.begin_series(); // The capacity each field's histogram index column has reached, `0` until its first // histogram. The columns are handed out inside the series, so what they are charged stays - // charged; only the growth of one series is charged at a time. - let mut index_capacity = vec![0usize; width]; + // charged; only the growth of one series is charged at a time. Only a caller accounting for + // the workspace reads the ledger, so an unaccounted merge allocates nothing for it. + let mut index_capacity = if budget.is_some() { + vec![0usize; width] + } else { + Vec::new() + }; samples.sort_unstable_by_key(|(point, field, _)| (*point, *field)); let mut samples = samples.into_iter().peekable(); let mut pushed = 0usize;