Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set cluster slot for scan commands, rather than random #2623

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Aug 8, 2023

  1. Set correct cluster slot for scan commands, similarly to Java's Jedis…

    … client
    
    - At present, the `scan` command is dispatched to a random slot.
    - As far as I can tell, the scanX family of commands are not cluster aware (e.g. don't redirect the client to the correct slot).
    - You can see [here](https://github.com/redis/jedis/blob/869dc0bb6625b85c8bf15bf1361bde485a304338/src/main/java/redis/clients/jedis/ShardedCommandObjects.java#L101), the Jedis client calling `processKey` on the match argument, and this is what this PR also does.
    
    We've had this patch running in production, and it seems to work well for us.
    
    For further thought:
    - Continuing looking at other Redis clients (e.g. Jedis), they outright [reject as invalid](https://github.com/redis/jedis/blob/869dc0bb6625b85c8bf15bf1361bde485a304338/src/main/java/redis/clients/jedis/ShardedCommandObjects.java#L98) any scan command that does not include a hash-tag. Presumably this has the advantage of users not being surprised when their scan produces no results when a random server is picked.
    - Perhaps it would be sensible for go-redis to do the same also?
    pete-woods committed Aug 8, 2023
    Configuration menu
    Copy the full SHA
    e0fbcea View commit details
    Browse the repository at this point in the history