What happens to client requests during a hash slot migration, and how does Redis Cluster handle keys that are in the middle of being moved?
Short answer
During migration, a slot briefly exists in a special migrating or importing state on the source and destination nodes, and if a client requests a key that has already moved, the node responds with a redirect telling the client exactly which node now holds that key, allowing…
Advertisement
AModel answer
During migration, a slot briefly exists in a special migrating or importing state on the source and destination nodes, and if a client requests a key that has already moved, the node responds with a redirect telling the client exactly which node now holds that key, allowing operations to continue correctly even while migration is actively in progress.
Example
-- A client might receive an ASK or MOVED redirect -- during an in progress slot migration (error) ASK 3999 destinationnode:6379
Real-world example
A properly built Redis Cluster client library automatically follows ASK and MOVED redirects during a live resharding operation, ensuring the application experiences no errors even while data is actively being redistributed in the background.
Likely follow-ups
- What is the difference between an ASK redirect and a MOVED redirect?
- Do all Redis client libraries handle these redirects automatically?
Related topics