Commit 218358bb authored by antirez's avatar antirez
Browse files

Cluster: conditions to clear "migrating" on slot for SETSLOT ... NODE changed.

If the slot is manually assigned to another node, clear the migrating
status regardless of the fact it was previously assigned to us or not,
as long as we no longer have keys for this slot.

This avoid a race during slots migration that may leave the slot in
migrating status in the source node, since it received an update message
from the destination node that is already claiming the slot.

This way we are sure that redis-trib at the end of the slot migration is
always able to close the slot correctly.
parent 3107e7ca
...@@ -3154,10 +3154,10 @@ void clusterCommand(redisClient *c) { ...@@ -3154,10 +3154,10 @@ void clusterCommand(redisClient *c) {
return; return;
} }
} }
/* If this node was the slot owner and the slot was marked as /* If this slot is in migrating status but we have no keys
* migrating, assigning the slot to another node will clear * for it assigning the slot to another node will clear
* the migratig status. */ * the migratig status. */
if (server.cluster->slots[slot] == myself && if (countKeysInSlot(slot) == 0 &&
server.cluster->migrating_slots_to[slot]) server.cluster->migrating_slots_to[slot])
server.cluster->migrating_slots_to[slot] = NULL; server.cluster->migrating_slots_to[slot] = NULL;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment