-
Notifications
You must be signed in to change notification settings - Fork 581
querymiddleware: cache instant query errors #11120
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
Conversation
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.
Changes LGTM assuming you've tested locally. Do you mind expanding the unit tests for this middleware to make sure instant queries behave how we expect?
022f49c
to
1fb59dc
Compare
@56quarters I've updated the tests and also ran the tests (see the updated description of the PR). PHAL |
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.
Thanks for adding tests but I don't think this will work as written. The way the cache key for errors is built includes req.GetStart()
and req.GetEnd()
in the key. For an instant query this is the timestamp the query is executed at which will be different for every instant query.
Additionally, the screenshots of testing you did indicate another bug. A context deadline exceeded error is a timeout and shouldn't be cached.
The first issue can be fix by changes to |
Opened #11198 to fix this |
Signed-off-by: Vladimir Varankin <vladimir.varankin@grafana.com>
Signed-off-by: Vladimir Varankin <vladimir.varankin@grafana.com>
Signed-off-by: Vladimir Varankin <vladimir.varankin@grafana.com>
Signed-off-by: Vladimir Varankin <vladimir.varankin@grafana.com>
6bc02e5
to
5bccd34
Compare
That's a great point. I've updated the default cache key generator to handle that. |
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 with a few comments. Thanks!
Signed-off-by: Vladimir Varankin <vladimir.varankin@grafana.com>
Signed-off-by: Vladimir Varankin <vladimir.varankin@grafana.com>
What this PR does
The PR adds errors caching middleware for instant query. This is basically the amendment to the original #9028
(I haven't tested it yet, but I think it should just work).Update I ran some manual testing in a dev environment, and it works as I'd expected:
Details
Non-cachable errors aren't cached:

Cachable errors are stored in the cache on first occurrence:

...and are retrived from the cache on subsequent requests

Which issue(s) this PR fixes or relates to
Fixes #11029
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]
.about-versioning.md
updated with experimental features.