Repository navigation
fix(tools): make scan_all_keys work in cluster mode - #212
Merged
Merged
Conversation
RedisCluster.scan returns a dict of per-node cursors, so the cursor == 0 check never matched and the dict was sent back as the next cursor. Use scan_iter, which handles both standalone and cluster cursors. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #212 +/- ##
==========================================
+ Coverage 88.20% 88.53% +0.32%
==========================================
Files 19 19
Lines 1060 1116 +56
==========================================
+ Hits 935 988 +53
- Misses 125 128 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
vchomakov
approved these changes
Nov 29, 2026
vchomakov
left a comment
Member
There was a problem hiding this comment.
Thanks, verified locally on a 6-node cluster (3 primaries, 3 replicas) and a standalone Redis.
LGTM.
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.
With
REDIS_CLUSTER_MODEenabled,scan_all_keysalways returns an error instead of the matching keys:Cause:
RedisCluster.scanreturns a dict of per-node cursors rather than a single integer. Thecursor == 0check never matches, and the dict is passed back as the next cursor.Fix: use
r.scan_iter(match=..., count=...), which redis-py implements for both standalone and cluster clients and which tracks each node's cursor. Byte decoding is unchanged.Verification: on a local 3-node cluster with 500
user:*keys andbatch_size=50,mainreturns the error above and this branch returns all 500 keys. The new test runs redis-py's own clusterscan_iterover a mockedSCAN; it fails onmainand passes here. The full test suite passes (389 tests), and ruff check/format are clean.Not changed:
scan_keysalso exposes the per-node cursor dict in cluster mode. Fixing it means deciding how a cluster cursor should look in the tool's interface, so it is left out of this PR.This change was prepared with AI assistance (Claude Code).