Skip to content

fix(redis_proxy): implement targeted SCAN support for sharded clusters#43114

Closed
SushanthMusham wants to merge 1 commit intoenvoyproxy:mainfrom
SushanthMusham:feature/redis-targeted-scan
Closed

fix(redis_proxy): implement targeted SCAN support for sharded clusters#43114
SushanthMusham wants to merge 1 commit intoenvoyproxy:mainfrom
SushanthMusham:feature/redis-targeted-scan

Conversation

@SushanthMusham
Copy link

Commit Message:
fix(redis_proxy): implement targeted SCAN support for sharded clusters

Additional Description:
This PR fixes the behavior of SCAN commands in sharded Redis clusters. Previously, the proxy did not correctly route SCAN commands to specific shards, leading to potential cursor loss or incorrect iteration.

The changes implement a targeted scan approach:

  1. Request Parsing: The proxy now detects cursors in the shard_index:cursor format (e.g., 2:15).
  2. Routing: It extracts the shard index and routes the command only to that specific shard, rather than broadcasting.
  3. Response Rewriting: When the backend responds, the proxy encodes the shard index back into the returned cursor so the client can continue scanning the same shard in the next request.

This ensures that clients can iterate through the entire sharded keyspace without "cursor amnesia."

Risk Level:
Low

Testing:
Manual verification was performed using redis-cli and a local Redis backend:

  • Verified that SCAN <invalid_shard>:0 correctly returns a "shard index out of bounds" error, confirming the parsing logic.
  • Verified that SCAN 0:0 successfully routes to the backend and returns a valid response.
  • Verified successful compilation with Bazel on macOS.

Docs Changes:
N/A

Release Notes:
redis_proxy: added support for targeted SCAN commands in sharded clusters using shard_index:cursor format.

Platform Specific Features:
N/A

Generative AI Usage:
I used AI assistance (Gemini) to help navigate the codebase, debug build issues, and draft the C++ logic for command_splitter_impl.cc. I have manually reviewed and tested the code to ensure its correctness.

@repokitteh-read-only
Copy link

Hi @SushanthMusham, welcome and thank you for your contribution.

We will try to review your Pull Request as quickly as possible.

In the meantime, please take a look at the contribution guidelines if you have not done so already.

🐱

Caused by: #43114 was opened by SushanthMusham.

see: more, trace.

Signed-off-by: DORAEMONlovesMICHAN <mushamsushanth@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant