Quick revision
The short answer
Most likely one very large key in the slot being moved took longer to serialise, transfer and restore than the MIGRATE timeout allowed, which explains both the IOERR and the 900 ms latency, since MIGRATE blocks both nodes while it handles a key. The slot was left MIGRATING on the source and IMPORTING on the target; clients still work through ASK redirects, but rebalancing is blocked until we close it with redis-cli --cluster fix or by hand with CLUSTER SETSLOT. Before rerunning, we find and split or rebuild the big key, then migrate off-peak in smaller steps with a longer timeout.
What to remember
In this answer, we traced the IOERR and the 900 ms latency to a single 400 MB sorted set that MIGRATE could not move within its timeout while blocking both nodes. We saw that the slot was left MIGRATING and IMPORTING, harmless for clients but blocking for rebalancing, found the key with GETKEYSINSLOT and MEMORY USAGE, removed or split it, closed the slot with --cluster fix or CLUSTER SETSLOT, and reran off-peak with smaller batches, a longer timeout and fewer slots at a time, noting newer atomic slot migration.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Most likely one very large key in the slot being moved took longer to serialise, transfer and restore than the MIGRATE timeout allowed, which explains both the IOERR and the 900 ms latency, since MIGRATE blocks both nodes while it handles a key. The slot was left MIGRATING on the source and IMPORTING on the target; clients still work through ASK redirects, but rebalancing is blocked until we close it with redis-cli --cluster fix or by hand with CLUSTER SETSLOT. Before rerunning, we find and split or rebuild the big key, then migrate off-peak in smaller steps with a longer timeout.
Why this question is asked
A rebalance that dies halfway leaves the cluster in an in-between state that is safe for clients but blocks further operations, and the instinct to just run it again usually hits the same wall. The useful skill is reading the symptoms: an IOERR from MIGRATE together with a latency spike on exactly the two shards involved points at one key that is too big to move comfortably. Interviewers ask this to see whether we understand how slot migration works internally and can repair it safely. In this answer, we will recap MIGRATE, diagnose the failure, close the open slot, deal with the big key, rerun safely and look at newer migration options.
1A Quick Recap of How Keys Move
During a reshard, a slot moves from a source primary to a target. The target is marked IMPORTING and the source MIGRATING for that slot. The tool then asks the source for keys in the slot and moves them in batches with MIGRATE. For each key, MIGRATE serialises the value on the source (like DUMP), sends it to the target, which restores it (like RESTORE), and deletes it from the source. Each key moves atomically, and both nodes are blocked while that key is handled. When the slot is empty, CLUSTER SETSLOT slot NODE target-id gives it to the target.
2Diagnosing the Failure
For ordinary keys of a few kilobytes, blocking takes microseconds. For a sorted set with 3 million members, serialising takes a long time, the payload may be hundreds of megabytes, and the target must rebuild the whole structure. Both nodes stay blocked throughout, which is why latency on exactly the source and target shards jumped to 900 ms. If the operation exceeds the timeout given to MIGRATE, the command fails with IOERR, the tool stops, and the slot stays half moved.
- Tool migrates slot 7008 in batchessource MIGRATING, target IMPORTING
- MIGRATE reaches a 400 MB sorted setboth nodes blocked while it is serialised and restored
- Done within the MIGRATE timeout?YesContinue with the next keysNoIOERR, tool stops
- Slot 7008 left half movedlatency spiked on both shards
4 steps in order. Play them, or step through them one at a time.
MEMORY USAGE on the remaining keys, or redis-cli --bigkeys on the source shard, finds the culprit quickly. Here a global leaderboard of 3 million members weighs about 400 MB.
3What the Half-Moved Slot Means
Clients are fine. The source still owns slot 7008. Keys that already moved are answered with an ASK redirect to the target, and the rest are served by the source. But the cluster is not clean: redis-cli --cluster check warns, and rebalance or reshard refuse to proceed with open slots. We need to finish the move or roll it back.
4Bringing the Cluster Back to a Clean State
The quickest path is redis-cli --cluster fix, which finds open slots and closes them, usually by moving the remaining keys and assigning the slot to one owner. But it would try to move the same giant key again, so we deal with that key first. With the key gone or split, either run fix, or finish by hand.
If the big key is real data, we split it in the application first: for example a leaderboard sharded into 64 sorted sets by user id, with a merge of the top entries when reading, or we move it during a planned window with a much longer timeout and accept the pause. UNLINK rather than DEL frees the memory in a background thread, so deleting it does not cause another stall.
5Rerunning the Migration Safely
With big keys out of the way, rerun in quieter hours, in smaller steps, and watch latency per shard as it goes. redis-cli lets us control the batch size and the timeout, and reshard can move a fixed number of slots at a time instead of rebalancing everything in one run.
Newer engine releases change this picture. Valkey 9 introduced atomic slot migration, which moves a whole slot as a replicated stream instead of key by key with MIGRATE, so a big key no longer blocks both nodes in one piece, and Redis has been adding its own improvements. Check what your version offers before planning large reshards.
6Follow-up questions
How would you find big keys across the cluster before the next rebalance?
Run redis-cli --bigkeys, and --memkeys where available, against every primary; they use SCAN, so they are safe but add some load, and are best run on replicas. For a full picture without touching production, analyse an RDB backup offline with an RDB analysis tool that lists key sizes. Then set an alert or a periodic report on keys above, say, 10 MB.
Can a half-moved slot lose data?
Not by itself. Each key is either on the source or the target, never both and never neither, because MIGRATE is atomic per key. The risk comes from manual mistakes, such as assigning the slot to the target while keys are still on the source, which makes those keys unreachable.
Why did latency spike on only two shards?
Because MIGRATE blocks only the source and the target while it handles a key. Other shards were not involved in that slot's migration.
7Conclusion
In this answer, we traced the IOERR and the 900 ms latency to a single 400 MB sorted set that MIGRATE could not move within its timeout while blocking both nodes. We saw that the slot was left MIGRATING and IMPORTING, harmless for clients but blocking for rebalancing, found the key with GETKEYSINSLOT and MEMORY USAGE, removed or split it, closed the slot with --cluster fix or CLUSTER SETSLOT, and reran off-peak with smaller batches, a longer timeout and fewer slots at a time, noting newer atomic slot migration.
Open with
The symptoms point at one big key. MIGRATE moves each key atomically, and while it serialises the value, sends it and the target restores it, both the source and the target are blocked.
Then, if they want more
A huge key, for example a sorted set with 3 million members, takes long enough to exceed the migration timeout, which gives the IOERR, and blocks both shards for hundreds of milliseconds, which explains the 900 millisecond spike on exactly two shards. The rebalance stopped with the slot MIGRATING on the source and IMPORTING on the target.
Clients still work through ASK redirects, but further rebalancing is blocked until the slot is closed. I would find the culprit with CLUSTER GETKEYSINSLOT on the open slot and MEMORY USAGE, or redis-cli bigkeys on the source shard.
If it is cache data, I would unlink it and let it be rebuilt; if not, I would split it in the application into smaller keys first. Then I close the slot with redis-cli cluster fix, or by hand by migrating the remaining keys and running CLUSTER SETSLOT NODE with the target's id.
Finally I rerun off-peak with a smaller pipeline and a larger cluster timeout, a range of slots at a time, watching latency per shard. I would also check whether our engine has atomic slot migration, as Valkey 9 added, before planning big reshards.
About this answer
- Last updated
- 13 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Redis documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "What most likely failed, how do you bring the cluster back to a clean state, and how do...": https://scrivio-interview-library.netlify.app/databases/redis-scaling/e99e5709cd/