Fix cache key collision in Query Frontend with epoch-aware shard keys - #5
Open
laurentketterle-hub wants to merge 1 commit into
Conversation
During tenant shuffle-sharding rebalance, the Query Frontend's cache key generation did not account for the active shard configuration, causing stale cached fragments from old shard assignments to be merged with new fragments. This resulted in partial/incomplete query results returned with HTTP 200 OK. Changes: - Add ShardConfig and CacheKey types with epoch-aware hashing (types.go) - Implement QueryRangeCache middleware that incorporates shard epoch in cache keys, bypasses cache during transitions, and supports proactive stale-epoch invalidation (cache.go) - Add comprehensive unit tests verifying key rotation, transition bypass, stale invalidation, and hash determinism (cache_test.go) - Update main.go with a demo showcasing the fix The cache key now includes a hash of the tenant's shard configuration, ensuring that when shards change (scale-out/scale-in/rebalance), cache keys naturally rotate and old fragments are never mixed with new ones. Closes rasoolharlym8#1 Signed-off-by: laurentketterle-hub <noreply@users.noreply.github.com>
|
😅 Unfortunately there are no rewards left to claim in this issue! |
This file contains hidden or 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
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.
Summary
During tenant shuffle-sharding rebalance, the Query Frontend intermittently merges cached query fragments generated by different shard assignments. Because the cache key generation did not account for the active shard configuration or transition state, fragments from the old shard assignment were mixed with fragments from the new shard assignment, resulting in partial/incomplete query results returned with HTTP 200 OK.
Fix
This PR implements epoch-aware cache keys in the Query Frontend:
ShardConfig and CacheKey types (pkg/queryfrontend/queryrange/types.go):
QueryRangeCache middleware (pkg/queryfrontend/queryrange/cache.go):
Unit tests (pkg/queryfrontend/queryrange/cache_test.go):
How It Works
Closes #1
/claim #1
Signed-off-by: laurentketterle-hub noreply@users.noreply.github.com