[release-2.8.x] caching: do not try to fill the gap in log results cache when the new query interval does not overlap the cached query interval #9783
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.
Backport 3e1f2fc from #9757
What this PR does / why we need it:
Currently, when we find a relevant cached negative response for a logs query, we do the following:
The problem with filling the gaps is that when the cached query does not overlap at all with the new query, we have to extend the query beyond what the query requests for. However, with the logs query, we have a limit on the number of lines we can send back in the response. So, this could result in the query response having logs which were not requested by the query, which then get filtered out by the response extractor, unexpectedly resulting in an empty response. For example, if the query was cached for start=15, end=20 and we get a
backwards
query for start=5, end=10. To fill the gap, the query would be executed for start=5, end=15. Now, if we have logs more than the querylimit
in the range 10-15, we would filter out all the data in the response extractor and send back an empty response to the user.This PR fixes the issue by doing the following changes when handling cache hit:
Special notes for your reviewer:
We could do further improvements in the handling of queries not overlapping with cached query by selectively extending the queries based on query direction and cached query lying before/after the new query. For example, if the new query is doing
backwards
query and thecachedQuery.End
<newQuery.Start
, it should be okay to extend the query and docachedQuery.End
tonewQuery.End
to fill the cache since query would first fill the most relevant data before hitting the limits. I did not want to complicate the fix so went without implementing this approach. We can revisit later if we feel we need to improve our caching.Checklist
CHANGELOG.md
updated