Back to results for “Migration”
Redis › Cluster Sharding & Hash Slots

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?

Advanced

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.
-- 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.

Common follow-ups: What is the difference between an ASK redirect and a MOVED redirect?;Do all Redis client libraries handle these redirects automatically?