Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable sharding of count/avg when labels are mutated #5474

Merged
merged 1 commit into from
Feb 25, 2022

Conversation

cyriltovena
Copy link
Contributor

What this PR does / why we need it:

Counting distinct values cannot be sharded when mutating labels over multiple shards, since the same label can appears across multiple shard and will be counted twice.

Since avg() uses count then the same logic is applied for it too.

Which issue(s) this PR fixes:
Fixes #5461

Special notes for your reviewer:

Checklist

  • Documentation added
  • Tests updated
  • Add an entry in the CHANGELOG.md about the changes.

@cyriltovena cyriltovena requested a review from a team as a code owner February 24, 2022 22:02
@@ -964,6 +962,18 @@ func (e *VectorAggregationExpr) String() string {

// impl SampleExpr
func (e *VectorAggregationExpr) Shardable() bool {
if e.Operation == OpTypeCount || e.Operation == OpTypeAvg {
Copy link
Member

Choose a reason for hiding this comment

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

We really need a way to express operations that aren't always or never shardable, but shardable depending on how they're combined with other operations. This is a great start 👍.

@cyriltovena cyriltovena merged commit a411bb9 into grafana:main Feb 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

count() result is inaccurate
2 participants