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.
This commit is contained in:
antirez 2014-02-10 23:48:42 +01:00
parent 3107e7ca60
commit 218358bbbd

View File

@ -3154,10 +3154,10 @@ void clusterCommand(redisClient *c) {
return;
}
}
/* If this node was the slot owner and the slot was marked as
* migrating, assigning the slot to another node will clear
/* If this slot is in migrating status but we have no keys
* for it assigning the slot to another node will clear
* 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] = NULL;