-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
promql: ensure series in matrix values returned for instant queries are sorted #14083
Conversation
Signed-off-by: Charles Korn <charles.korn@grafana.com>
…s sorted Signed-off-by: Charles Korn <charles.korn@grafana.com>
a4d2068
to
036c872
Compare
/prombench main |
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.
Looks good, one suggestion and I started prombench.
Signed-off-by: Charles Korn <charles.korn@grafana.com>
/prombench cancel |
Benchmark cancel is in progress. |
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.
LGTM
Thanks.
Taking a look at the benchmark dashboards, I can see some overhead in the |
Running the benchmarks would help quantify the overhead? |
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.
Do you think this behaviour is documented anywhere?
I think it should be. Anyway we can go ahead with the change.
We did run prombench, although it doesn't have this kind of query. I don't think there are any benchmarks which currently test the case of an instant query returning a matrix. Would you like to write some? |
I couldn't find it documented anywhere. Perhaps here makes sense? Should we also require instant vectors to be sorted by series as well? Seems like this would be good for the sake of consistency. |
👍
The code takes care not to do that, since there are PromQL functions like |
Related: the code silently ignores any [when multiple points are returned, which set do you sort on?] |
Also related: |
Signed-off-by: Charles Korn <charles.korn@grafana.com>
I've created #14115 so we don't lose this. |
# Conflicts: # promql/engine_test.go
I've resolved the merge conflicts. The CI failure seems to be an unrelated flake. |
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.
LGTM, thanks!
The PromQL engine always sorts matrix values returned for range queries (source), but does not do the same thing for matrix values returned for instant queries.
This PR makes the behaviour for instant queries consistent with range queries: matrix values are now always sorted by series.
I've added the
TestInstantQueryWithRangeVectorSelector/matches series with points in range
test case to demonstrate the issue and that it has been fixed. (Note that without the fix, the series order is unpredictable, so you may need to run the test multiple times to see the failure.)I've also added some other test cases for instant queries that return matrices given there weren't any test cases for this scenario.