fix: bound key SCAN by type filter to stop infinite loop#58
Open
ytkimirti wants to merge 1 commit into
Open
Conversation
Filtering keys by a sparse or absent type (e.g. set/list on a hash-heavy db) made scanUntilAvailable walk the entire keyspace looking for a match — effectively an infinite loop that hammers the db. Upstash REST also caps SCAN at ~1000 keys/call, so raising COUNT can't fix it. - Cap SCAN round-trips per fetch (MAX_SCANS_PER_FETCH); pause and let the user resume via a "Keep scanning" action instead of looping. - Thread React Query's abort signal so changing the filter cancels the in-flight scan instead of fetching in the background. - Raise the COUNT ceiling to the 1000 server cap.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Problem
Filtering keys by a type that's sparse or absent in the db (e.g.
set/liston a hash-heavy database) made the key list scan loop forever.scanUntilAvailablekept issuingSCAN ... TYPE <x>until it found a match or walked the entire keyspace — on a 45M-key db that's tens of thousands of requests hammering Redis with no visible result. RaisingCOUNTcan't help: Upstash REST caps SCAN at ~1000 keys/call regardless of COUNT (measured). Switching the filter mid-scan also didn't cancel the in-flight loop, so it kept fetching in the background.Fix
MAX_SCANS_PER_FETCH). When the budget is spent with no match, pause and show a Keep scanning action instead of looping.signalinto the scan loop so changing the filter/type cancels it immediately.Closes DX-2789