Skip to content

fix(collector views): fill a collector view's label columns from the series labels - #899

Draft
zzylol wants to merge 2 commits into
feat/collector-state-lineagefrom
fix/collector-view-label-columns
Draft

zzylol wants to merge 2 commits into
feat/collector-state-lineagefrom
fix/collector-view-label-columns

Conversation

@zzylol

@zzylol zzylol commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Problem: when a workload includes max by (region, service) (quantile_over_time(0.99, data[1m])), the plan has a second DDSketch chain that keeps region and service beside the series identity. As a collector view, that chain made the data plane refuse to start: collector view 11: its rows have column region, which a collector state does not carry.
  • Change: the chain is still one row per series, and every collector state carries its series' labels. So each text column of a collector view over a Scan is now filled from the state's series labels, empty when the series lacks the label. A raw-data read fills a label column the same way.
  • Effect: the grouped query plans, installs and answers in the collector arm. On the live demo (W3 plus this query, 10k series at 10 samples/s), its answers equal the raw-ingest arm's (A == B ratio 1.0000 over 60 samples), and it stays within 5% of Prometheus (max relative error 4.997%, every point within 5%).

Review guide

Behavior: before → after

The workload is W3's four quantile queries plus max by (region, service) (quantile_over_time(0.99, data[1m])) at a 5% target, every 5 s. data has 10k series with region, service, job and label_0 labels. The control plane plans two DDSketch chains:

  • view 1, for the ungrouped queries, with rows (window end, $promql_series_identity, state);
  • view 12, with rows (window end, region, service, $promql_series_identity, state).

Both chains read the Scan of data directly. --emit-collector-views lists [1, 12] for the collector.

before after
data_plane --collector-views cv.json startup fails: collector view 12: its rows have column region, which a collector state does not carry starts; views 1 and 12 commit a window per 5 s
grouped query in the collector arm not answered 20 (region, service) series, equal to the raw-ingest arm

Interfaces

None. CollectorView (private) gains a label_columns: Vec<(usize, String)> field.

Algorithm changes

Which collector views install, and how a collector window's rows are built.

  • Before: a view's rows had to be exactly a window end, a series identity and a state. Any other plain column was refused.
  • After:
    1. When the view's input is a Scan, each Utf8 column other than the series identity is a label column.
    2. rows sets it to series.labels()[name], or "" when the series lacks that label (as ColumnKind::Label in a raw-data read).
    3. Any other plain column is still refused. So is a text column of a view whose input is not a Scan, such as a Project that could compute its own text.
  • Correctness: a view over a Scan keeps a series identity, so it is per series (PerEntity). The Scan's text columns are the series' labels, which are functions of the series. The state's row therefore holds the same values the view's own run writes from raw samples. a_collector_views_label_columns_come_from_its_series_labels checks a full label set and a series missing service, and the demo checks the grouped query against the raw-ingest arm.
  • Complexity: one label lookup and one string per label per row. The view store then dictionary-encodes the column as it does for a computed window.
  • Assumptions and limits: the planner keeps a separate, wider chain for the grouped query rather than sharing view 1. The collector therefore sends both views' states, so the series are sent twice. Sharing the narrower view is a planner decision and is not part of this PR.

Decisions and open questions

None.

Verification

scope result notes
precompute --lib collector 6 passed new: a_collector_views_label_columns_come_from_its_series_labels (a grouped query's chain installs as a collector view; rows take region/service from the series, "" when missing). It failed first with the demo's exact error.
cargo fmt --check; cargo clippy -p precompute --all-targets -D warnings clean

Live demo (binary = #893 + #894 + #898 + this PR; W3 plus the grouped query; 5-minute window after 7 minutes of running):

max by (region, service) (quantile_over_time(0.99, data[1m])) A (collector) B (raw ingest) C (Prometheus)
series 20 20 20
max relative error vs C 4.997 % 4.997 % exact
within 5 %, min 1.000 1.000
A == B ratio, min (60 samples) 1.0000

The other four W3 queries stay at A == B 1.0000 and within 5% 1.000 in the same window. A's ASAPQuery-backend ran at 0.200 cores and B's at 0.298 cores.

Follow-ups

  • The planner could let the grouped query read view 1 (per-series states) and keep the labels from the series identity, instead of planning a second chain. That would halve the collector's states for this workload. It is a planner decision and is left out here.

🤖 Generated with Claude Code

https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf

zzylol and others added 2 commits November 30, 2026 16:00
…the series (failing first)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
…series labels

A grouped query's chain over a Scan keeps its grouping labels (e.g.
region, service) beside the series identity. Its rows are still one per
series, so each label is the state's series' label, empty when the
series lacks it, as a raw-data read fills a label column. Such a view
was refused at startup ("its rows have column region, which a collector
state does not carry"). A text column of a view not directly over a Scan
is still refused: it need not be a series label.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6bo8kYWd83zXwh2Nobf
@zzylol zzylol added bug Something isn't working area: data plane Runtime ingestion, storage, and query-serving data paths labels Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: data plane Runtime ingestion, storage, and query-serving data paths bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant