Repository navigation
test(planner): counter rate and increase answers, installed and at query time - #1343
Merged
Merged
Conversation
…ery time Hand-worked answers of rate and increase over a counter, per series, per job and in total, on deployments that keep raw data and that do not, answered two ways: as installed (each tumbling-window chain built window by window in ingestion runs and read from its materialized view) and with the whole plan run in the query run from the raw samples. The query-run test fails today: a chain placed at ingestion time and run in the query run builds only its newest 10 s window, so a counter's per-series rows are dropped (fewer than two samples) and the grouped query answers no rows.
zzylol
force-pushed
the
test/1338-counter-rate-answers
branch
from
November 16, 2026 04:42
4970361 to
697178e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sum by (job)(rate(requests_total[5m]))andsum by (job)(increase(requests_total[5m]))return no rows when the selected plan runs in one query run over the raw samples. Nothing tests this.rateandincreaseper series, per job and in total against hand-worked answers. Each query is answered two ways (as installed, and in a query run over the raw samples), on a deployment that keeps raw data and on one that does not.mainfor 8 of 12 cases. Example:sum by (job)(increase(requests_total[5m]))answers[]; the expected answer isj1: 60, j2: 140. The fix PR stacked on this one makes it pass.Refs #1338.
Review guide
main. The fix PR (closes sum by (job)(rate|increase(counter[5m])) plans and installs but answers no rows #1338) is stacked on this branch.crates/planner/tests/runtime_install.rs, section "Counter rate and increase, per series and per group". Start withcounter_queries(the hand-worked answers) andinstalled_answers(the runtime-like data plane).time_series::runnow takes the materialized views to bind (existing callers pass&[]), and runs an ingestion scope withexecute_ingestion.Rebased onto main
863153e3cHead
697178e05(was49703618e) is rebased ontomain863153e3c(after #1237, #1242, #1309, #1339, #1330, #1324 and #1300). Conflicts and resolutions, all in the tests:crates/planner/tests/runtime_install.rs:mainmoved the sample,run,answersandassert_answers_nearhelpers into the sharedtests/time_seriesmodule and deletedCountingStore. This PR's copies are dropped.counter_samplesandcounter_queriesnow build their samples and label sets withtime_series::sampleandlabels.installed_answersbuilds one store (time_series_tablesplusappend_materialized_viewfor each view's windows), so theWindowStatealias is gone.crates/planner/tests/time_series/mod.rs:runtakesviews: &[MaterializedView], the views it binds as materialized view slots. Its callers inmetricsql_workloads.rsandreduce_aggregates.rspass&[]. Since the runtime change inmain(fix(executor): run each node by its plan Lifetime, so roots drain in any order #1300), it runs an ingestion scope throughexecute_ingestionand a query scope throughexecute.Example and cause (what the tests show)
The workload: one query every 10 s within relative error 0.01. The source is 1,000
requests_totalcounter series sampled every second. The test data is four series,a..d. Jobsj1= {a, b} andj2= {c, d}. Each series has one sample every 15 s over the 8 minutes before T. Seriesicounts(i + 1) * step.The selected plan for the grouped query:
sum by (job)(increase(..[5m]))at TIn the query run, the chain at ingestion time is built as an ingestion run builds it: only its newest window, (T − 10 s, T]. Each series has at most one sample there, and the finalize drops a counter with fewer than two samples. This is the harness that #1338 and the MetricsQL test use (
compile(&plan.dag, &[], roots)).Interfaces
None (tests only).
Algorithm changes
None.
Design scope
No new types or files. The new helpers stay inside the existing
runtime_install.rstest file, which tests installing and running plans as a deployment runtime does:plan_counter_query,counter_samples,counter_queries,installed_answersandcounter_query_mismatches.Decisions and open questions
None.
Verification
On
697178e05, compared by test name withmain863153e3cbuilt the same way:maincargo check --workspace --all-targetscargo fmt --all -- --checkcargo clippy -p asap-executor -p asap-planner --all-targets -- -D warningscargo nextest run -p asap-executorcargo nextest run -p asap-planner --test planner(includesruntime_install,metricsql_workloads,reduce_aggregatesovertime_series)runtime_install::counter_rates_and_increases_answer_at_query_time_from_raw_samples(8 of 12 cases answer[]).summary_sharing::identical_ungrouped_queries_share_their_producersfails onmaintooNew tests:
counter_rates_and_increases_answer_from_views_built_at_ingestion_time: each chain view is refreshed window by window in ingestion runs, then the query run reads the views. Passes onmain, so the installed path was already correct.counter_rates_and_increases_answer_at_query_time_from_raw_samples: the whole plan runs in one query run over the raw samples. Fails onmain.Hand-worked answers: over
[5m]each series has 20 samples (steps 13..=32),(i + 1) * 19apart over 285 s. The start gap is 15 s, which is under 1.1 sample intervals, so the increase extrapolates to the full 300 s:(i + 1) * 20. The rate is that divided by 300 s. So increase is j1 60, j2 140, total 200, and rate is j1 0.2, j2 0.4667, total 0.6667.Follow-ups
The fix PR stacked on this one.