-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
fix: (Bug) correct resultType when storing instant query results in cache #12312
Merged
+222
−28
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…cache. Previously the results cache for instant metric query is stored as wrong type `TypeMatrix` so some of the results were ignored during final computation. This PR fixes the correct type `TypeVector` Signed-off-by: Kaviraj <[email protected]>
kavirajk
changed the title
[WIP] bugfix: Fix correct resultType when storing instant query results in cache
fix: correct resultType when storing instant query results in cache
Mar 22, 2024
kavirajk
changed the title
fix: correct resultType when storing instant query results in cache
fix: (Bug) correct resultType when storing instant query results in cache
Mar 22, 2024
Signed-off-by: Kaviraj <[email protected]>
sandeepsukhani
approved these changes
Mar 26, 2024
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
trevorwhitney
added a commit
that referenced
this pull request
Apr 1, 2024
commit 018856c Author: Callum Styan <[email protected]> Date: Mon Apr 1 06:40:16 2024 -0700 fix: fix span logging based on changes to request types timestamps (#12393) Signed-off-by: Callum Styan <[email protected]> commit 5190dda Author: Shantanu Alshi <[email protected]> Date: Mon Apr 1 18:30:21 2024 +0530 feat(detected_labels): Initial skeleton for the API (#12390) Co-authored-by: Cyril Tovena <[email protected]> commit 0b7ff48 Author: Sandeep Sukhani <[email protected]> Date: Mon Apr 1 14:21:50 2024 +0530 chore: delete request processing improvements (#12259) commit a509871 Author: Ed Welch <[email protected]> Date: Sun Mar 31 22:14:21 2024 -0400 chore: remove experimental flags for l2 cache and memcached "addresses" config (#12410) commit 7480468 Author: Kaviraj Kanagaraj <[email protected]> Date: Sun Mar 31 18:00:53 2024 +0200 fix: (Bug) correct resultType when storing instant query results in cache (#12312) Signed-off-by: Kaviraj <[email protected]> commit 246623f Author: Trevor Whitney <[email protected]> Date: Fri Mar 29 17:05:36 2024 -0600 fix(detected_fields): fix issues with frontend integration (#12406) This PRs fixes issues we found when integrating with the frontend * the `/experimental` api made it difficult to interact with using the existing datasource, so move to `v1/detected_fields` * the config flag was considered cumbersome as the only potential negative impact of the endpoint is when it is used, and nothing is currently using it * the use of an enum in the protobuf produced unexpected results in the json, so type was converted to string
rhnasc
pushed a commit
to inloco/loki
that referenced
this pull request
Apr 12, 2024
…ache (grafana#12312) Signed-off-by: Kaviraj <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
tldr; Previously the results cache for instant metric query is stored as wrong type
TypeMatrix
so some of the results were ignored during final computation. This PR fixes the correct typeTypeVector
Before
First query will miss the cache and store it in the cache after downstream requests. Second request fetch from the cache. NOTE both are are same (bug)
After
NOTE: both first (without cache) and second (with cache) have same results
Detail explanation
The bug is the assumption of existing
ResultCache
that it always works withrange
queries everytime it has to storeLokiPromResponse
in the cache. But in reality we share the same response for both instant and range queries. With adding support for instant queries recently.But I failed to update the case where ResultsCache whenever trying to merge the multiple cache entries (we call
Extent
) it create new bigger response type (LokiPromResponse
) withresultType
set tomatrix
(assuming only range queries uses it)So when the cache is hit and these values are returned for computing the merged responses, it considers only samples with resultType
vector
(because it's instant query). That's the reason, when original query split into multiple subqueries and some of those subqueries even though hit cache, it's value is ignored in the final computation. Hence wrong results.Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Checklist
CONTRIBUTING.md
guide (required)CHANGELOG.md
updatedadd-to-release-notes
labeldocs/sources/setup/upgrade/_index.md
production/helm/loki/Chart.yaml
and updateproduction/helm/loki/CHANGELOG.md
andproduction/helm/loki/README.md
. Example PRdeprecated-config.yaml
anddeleted-config.yaml
files respectively in thetools/deprecated-config-checker
directory. Example PR