Skip to content

fix: reject duplicate label sets after dropping the metric name - #490

Closed
zzylol wants to merge 1 commit into
feat/per-series-binaryfrom
fix/series-labels-duplicates
Closed

zzylol wants to merge 1 commit into
feat/per-series-binaryfrom
fix/series-labels-duplicates

Conversation

@zzylol

@zzylol zzylol commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #489.

Why

PromQL arithmetic with a literal drops __name__. If two series then have the same label set, Prometheus fails with "vector cannot contain metrics with the same labelset". An independent review of backend #801 found that Planner returned both rows instead.

What

Before this PR

Series m{job="api",instance="x"} and n{job="api",instance="x"}, evaluated as sum_over_time(m[5m]) * 2, returned two identical {instance="x",job="api"} series. The Fallback a * 2 returned rows that still had __name__="a".

After this PR

Both paths fail with vector cannot contain metrics with the same labelset. Series that stay distinct are unaffected, and the Fallback a * 2 now drops __name__.

Validation

  • New regression tests fail before the fix and pass after it: per_series_scalar_arithmetic_rejects_label_sets_equal_without_the_name and literal_arithmetic_drops_the_name_and_rejects_equal_label_sets. A new without case confirms that series equal after dropping the name are grouped, not rejected.
  • cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace --no-fail-fast: all pass.

🤖 Generated with Claude Code

PromQL arithmetic with a literal drops `__name__`; if two series then
share a label set, Prometheus errors ("vector cannot contain metrics with
the same labelset"). The per-series literal path returned both rows, and
the Fallback literal path kept `__name__` altogether.

Add `Operator::series_without_name`, a `SeriesLabels` rewrite that errors
on equal resulting label sets, and use it for both literal paths. Matching
and `without` relabeling still tolerate repeats: `series_binary` already
rejects right-hand and matched left-hand duplicates, and aggregation
merges them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zzylol
zzylol force-pushed the feat/per-series-binary branch from 3f0d2e2 to 000c1ef Compare September 30, 2026 20:24
@zzylol
zzylol force-pushed the fix/series-labels-duplicates branch from ad45318 to d0f5f97 Compare September 30, 2026 20:24
zzylol added a commit that referenced this pull request Oct 1, 2026
…togram_quantile (#489, #490, #492, #494, #493)

Per-series vector arithmetic with Prometheus summation, duplicate label-set rejection, comparisons and set operators, rejection of fill modifiers, and histogram_quantile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zzylol

zzylol commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Included in the squash merge of #493 into main (deb3904).

@zzylol zzylol closed this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant