-
Notifications
You must be signed in to change notification settings - Fork 634
MQE: fix possible panic while evaluating a query containing group_left
or group_right
#11690
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
MQE: fix possible panic while evaluating a query containing group_left
or group_right
#11690
Conversation
…d panic if the binary operator is closed early
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks reasonable and tests seem covering all the edge cases now.
Follow up comment that can be done on the separate PR.
All instances of types.SomeSlicePool.Put(slice, ..)
is always followed by setting slice = nil
. Should we nil the slice inside the Put instead to avoid missed setting that up like this?
We can't nil the slice inside the |
…ft` or `group_right` (#11690) (#11692) * Fix test names * Test case where operator is closed before any series are read * Fix issue where a query containing `group_left` or `group_right` could panic if the binary operator is closed early (cherry picked from commit db7d12b) Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
…ft` or `group_right` (#11690) (#11695) * Fix test names * Test case where operator is closed before any series are read * Fix issue where a query containing `group_left` or `group_right` could panic if the binary operator is closed early (cherry picked from commit db7d12b) Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
…ft` or `group_right` (#11690) (#11693) * Fix test names * Test case where operator is closed before any series are read * Fix issue where a query containing `group_left` or `group_right` could panic if the binary operator is closed early (cherry picked from commit db7d12b) Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
…ft` or `group_right` (#11690) (#11696) * Fix test names * Test case where operator is closed before any series are read * Fix issue where a query containing `group_left` or `group_right` could panic if the binary operator is closed early (cherry picked from commit db7d12b) Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
…ft` or `group_right` (#11690) (#11694) * Fix test names * Test case where operator is closed before any series are read * Fix issue where a query containing `group_left` or `group_right` could panic if the binary operator is closed early (cherry picked from commit db7d12b) Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
Another way to go would be to have This would be a bit more ugly in the code, but perhaps easier to use? |
#### What this PR does This PR is an alternative to #11741, which implements an idea from @bboreham [here](#11690 (comment)). Compared to #11741, this avoids a need for a linter, at the cost of a slightly less obvious behaviour and slightly uglier code. #### Which issue(s) this PR fixes or relates to #11690 #### Checklist - [x] Tests updated. - [n/a] Documentation added. - [n/a] `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. - [n/a] [`about-versioning.md`](https://github.com/grafana/mimir/blob/main/docs/sources/mimir/configure/about-versioning.md) updated with experimental features.
What this PR does
This PR fixes an issue where queriers could panic with
estimated memory consumption of this query is negative
while evaluating a query containing a one-to-many or many-to-one binary operation (akagroup_left
/group_right
).Specifically, the issue is triggered if all of the series with the same group matching labels on the "one" side are read and then the operator is closed before all of the corresponding output series have been emitted. (This can happen if, for example, the query contains further binary operations that only need a subset of the output series.)
In this case, the
matchGroup
'spresence
slice would be returned to the pool multiple times: once inupdateOneSidePresence
, and again whenoneSide.Close
was called by the first remaining output series in that group.Which issue(s) this PR fixes or relates to
(none)
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]
.about-versioning.md
updated with experimental features.