Skip to content
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

query-frontend: Fix cache keys for dynamic split intervals #7832

Merged
merged 3 commits into from
Nov 5, 2024

Conversation

lachruzam
Copy link
Contributor

@lachruzam lachruzam commented Oct 15, 2024

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

The same interval is used for query splitting and cache key generation (the split interval is stored in requests created during the split).
Split interval has been added to cache keys to avoid overlaps for queries based on different intervals.
Support for caching generic PrometheusRequest has been removed - already PrometheusRequest was not been created by any configured decoder.

Verification

Run local tests make test, run query-frontend on a test environment.

@lachruzam
Copy link
Contributor Author

e2e run locally after a few retries

@lachruzam lachruzam force-pushed the qf-fix-cache-for-dynamic-intervals branch from 9355e26 to f808233 Compare October 16, 2024 11:57
}
return fmt.Sprintf("fe:%s:%s:%d:%d", userID, r.GetQuery(), r.GetStep(), currentInterval)

return "request_type_not_supported"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a condition that we should never hit in prod, right? Perhaps we should just panic() here?

Copy link
Contributor Author

@lachruzam lachruzam Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaced

switch tr := r.(type) {
case *ThanosQueryRangeRequest:
i := 0
for ; i < len(t.resolutions) && t.resolutions[i] > tr.MaxSourceResolution; i++ {
}
shardInfoKey := generateShardInfoKey(tr)
return fmt.Sprintf("fe:%s:%s:%d:%d:%d:%s:%d:%s", userID, tr.Query, tr.Step, currentInterval, i, shardInfoKey, tr.LookbackDelta, tr.Engine)
splitInterval := tr.SplitInterval.Milliseconds()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it's possible to write a function for these splitInterval/currentInterval calculations instead of copy/paste

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored.

@lachruzam lachruzam force-pushed the qf-fix-cache-for-dynamic-intervals branch 2 times, most recently from 86930d4 to 6554d24 Compare October 17, 2024 13:56
@lachruzam
Copy link
Contributor Author

@pedro-stanaka maybe you'd like to voice your opinion here

yeya24
yeya24 previously approved these changes Nov 3, 2024
Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense to me. Thanks for the fix

@yeya24 yeya24 enabled auto-merge (squash) November 5, 2024 05:58
@yeya24 yeya24 disabled auto-merge November 5, 2024 05:58
@yeya24 yeya24 enabled auto-merge (squash) November 5, 2024 05:58
@yeya24
Copy link
Contributor

yeya24 commented Nov 5, 2024

Thanos unit tests Expected — Waiting for status to be reported
I am not sure why it is blocked here and I cant merge the PR due to this. Maybe you can try to close and reopen this PR and see if CI got re-triggered?

@GiedriusS
Copy link
Member

I think you need to rebase on top of latest main to get the github actions changes

auto-merge was automatically disabled November 5, 2024 18:57

Head branch was pushed to by a user without write access

Signed-off-by: Michał Mazur <mmazur.box@gmail.com>
Signed-off-by: Michał Mazur <mmazur.box@gmail.com>
Signed-off-by: Michał Mazur <mmazur.box@gmail.com>
@lachruzam lachruzam force-pushed the qf-fix-cache-for-dynamic-intervals branch from f30035d to d4725c3 Compare November 5, 2024 19:29
@lachruzam
Copy link
Contributor Author

@yeya24 Rebased without any new change.

@yeya24 yeya24 merged commit ebfc03e into thanos-io:main Nov 5, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants