Skip to content

MQE: Ensure we never skip buckets for histogram_stddev and histogram_stdvar - #16486

Merged
zenador merged 3 commits into
mainfrom
zenador/mqe-dont-skip-buckets
Sep 1, 2026
Merged

MQE: Ensure we never skip buckets for histogram_stddev and histogram_stdvar#16486
zenador merged 3 commits into
mainfrom
zenador/mqe-dont-skip-buckets

Conversation

@zenador

@zenador zenador commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

What this PR does

See title. This doesn't change most queries as we already don't skip the buckets by default, just making the intended behaviour explicit and adding tests to cover it to prevent inadvertent changes to this behaviour later. This matches what we do in Prometheus.

However, it does change queries where either histogram_stddev or histogram_stdvar is nested under histogram_count, histogram_sum or histogram_avg (for example histogram_sum(h * histogram_stddev(h))), as the inner selector could return histograms without buckets, causing these functions to return 0. Added this edge case in a test and updated the changelog.

Which issue(s) this PR fixes or relates to

Parallel to upstream PR: prometheus/prometheus#19521

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]. If changelog entry is not needed, please add the changelog-not-needed label to the PR.
  • about-versioning.md updated with experimental features.

@zenador
zenador requested a review from a team as a code owner August 26, 2026 22:09
@zenador zenador added the changelog-not-needed PRs that don't need a CHANGELOG.md entry label Aug 26, 2026
@zenador
zenador force-pushed the zenador/mqe-dont-skip-buckets branch from 0a36c16 to 3931ca0 Compare August 27, 2026 01:40
@zenador zenador removed the changelog-not-needed PRs that don't need a CHANGELOG.md entry label Aug 27, 2026
@zenador

zenador commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

cc @krajorama

56quarters
56quarters previously approved these changes Aug 27, 2026

@56quarters 56quarters left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread CHANGELOG.md Outdated
* [BUGFIX] MQE: Fix an issue where series were joined in binary operations using the wrong labels when `group_left()`/`group_right()` were used in combination with `ignoring()`. This bug manifested as valid queries returning an error `grouping labels must ensure unique matches`. #16387
* [BUGFIX] MQE: Fix queries and rules containing a subquery whose range is shorter than its step (e.g. `foo[10m:3d]`) failing with `last bucket must not be before first bucket`. #16442
* [BUGFIX] MQE: Fix `sum_over_time()` over native histograms losing precision when experimental range vector splitting is enabled. The Kahan compensation of each split range was discarded instead of being carried over to the other split ranges. #16455
* [BUGFIX] MQE: Never skip decoding histogram buckets for `histogram_stddev` and `histogram_stdvar`. #16486

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can you clarify what issue this would have caused for users? Incorrect results?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, is it okay now?

@zenador
zenador merged commit e0acba1 into main Sep 1, 2026
91 checks passed
@zenador
zenador deleted the zenador/mqe-dont-skip-buckets branch September 1, 2026 17:59
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.

2 participants