fix(nodestore): Avoid full bigtable scans in get_multi#91976
Merged
Conversation
Codecov ReportAttention: Patch coverage is
|
| Files with missing lines | Patch % | Lines |
|---|---|---|
| src/sentry/utils/kvstore/bigtable.py | 33.33% | 2 Missing |
Additional details and impacted files
@@ Coverage Diff @@
## master #91976 +/- ##
==========================================
+ Coverage 81.60% 87.63% +6.02%
==========================================
Files 10355 10355
Lines 587356 587463 +107
Branches 22586 22586
==========================================
+ Hits 479306 514810 +35504
+ Misses 107623 72226 -35397
Partials 427 427
wedamija
approved these changes
May 20, 2025
wedamija
left a comment
Member
There was a problem hiding this comment.
It might be a good idea to put a warning or something inside of _get_bytes_multi too if we pass an empty list of ids
Member
Author
Member
andrewshie-sentry
pushed a commit
that referenced
this pull request
Jun 2, 2025
Add an id_list deduplication so that we can correctly recognize cache hits and avoid full table scans in bigtable. Add a test that demonstrates the fix. We observed some timeouts in nodestore.get_multi calls, with lookups for a small number of IDs taking 40s+. One commonality was that they were lookups that included duplicated IDs and cache hits; this is because we recognize full cache hits by comparing cached records to len(id_list), return if they are equal, and otherwise pass on id_list with cached IDs removed to bigtable get_bytes_multi. With dupes removed, id_list is empty, and the resulting row_scan to bigtable is unconstrained, meaning it either won't finish, or will return irrelevant data. Duplicates aren't visible in the result, so deduping early avoid this issue and any others that might result from repeated keys.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Add an id_list deduplication so that we can correctly recognize cache hits and avoid full table scans in bigtable.
Add a test that demonstrates the fix.
We observed some timeouts in nodestore.get_multi calls, with lookups for a small number of IDs taking 40s+.
One commonality was that they were lookups that included duplicated IDs and cache hits; this is because we
recognize full cache hits by comparing cached records to len(id_list), return if they are equal, and otherwise
pass on id_list with cached IDs removed to bigtable get_bytes_multi. With dupes removed, id_list is empty,
and the resulting row_scan to bigtable is unconstrained, meaning it either won't finish, or will return irrelevant data.
Duplicates aren't visible in the result, so deduping early avoid this issue and any others that might result from repeated keys.