-
Notifications
You must be signed in to change notification settings - Fork 64
Fix correctness issue in predict_linear with step invariant #527
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: 🌲 Harry 🌊 John 🏔 <[email protected]>
Signed-off-by: 🌲 Harry 🌊 John 🏔 <[email protected]>
Signed-off-by: 🌲 Harry 🌊 John 🏔 <[email protected]>
2ec4376
to
a43f047
Compare
query: `predict_linear({__name__="http_requests_total",pod!~"nginx-1"}[5m] @ start(), -0.37690610678629094)`, | ||
end: time.Unix(600, 0), | ||
start: time.Unix(300, 0), | ||
}, |
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.
Is this an issue for predict linear only or it can impact any function that takes matrix selector with step invariant?
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.
It will only impact functions that are at modifier unsafe that takes matrix selector as arg.
So far only applicable to predict_linear.
Can we just wrap the matrix function into step invariant operator? https://github.com/thanos-io/promql-engine/blob/main/execution/step_invariant/step_invariant.go#L47 ? |
We could just push step inviarnace up in a preprocessor like here: https://github.com/thanos-io/promql-engine/blob/main/logicalplan/plan.go#L335 |
The PromQL parser parses the query into: After calling promql.PreprocessExpr() in plan.go this becomes: In Prometheus, predict_linear is marked as at modifier unsafe. So it cannot be wrapped with StepInvariance: |
I see, I wonder if we maybe should jsut fall back for now for correctness sake - this seems to be fairly niche usecase that we must weigh against added complexity |
I'm okay with doing the fallback. There is one concern, we'll have to exclude the functions.test file from acceptance tests. |
Issue
Our continuous correctness tests found an issue with predict_linear with step invariant matrix selector.
Eg:
predict_linear({__name__="http_requests_total", pod!~"nginx-1"}[5m] @ start(), -0.37690610678629094)
This PR addresses the problem by allowing the matrixScanner to act in an invariant way similar to Prometheus engine.
See: https://github.com/prometheus/prometheus/blob/2a5ed8b8a55fecaa79236ef4adb9f0b82b34587c/promql/engine.go#L1788