1
0
mirror of https://github.com/fluencelabs/redis synced 2025-03-31 14:51:04 +00:00

clear importing/exporing state when appropriate on SETSLOT or ADDSLOTS cluster commands

This commit is contained in:
antirez 2011-05-06 16:08:10 +02:00
parent f9cbdcb1a6
commit 0caa750748

@ -1222,9 +1222,15 @@ void clusterCommand(redisClient *c) {
} }
for (j = 0; j < REDIS_CLUSTER_SLOTS; j++) { for (j = 0; j < REDIS_CLUSTER_SLOTS; j++) {
if (slots[j]) { if (slots[j]) {
int retval = del ? clusterDelSlot(j) : int retval;
clusterAddSlot(server.cluster.myself,j);
/* If this slot was set as importing we can clear this
* state as now we are the real owner of the slot. */
if (server.cluster.importing_slots_from[j])
server.cluster.importing_slots_from[j] = NULL;
retval = del ? clusterDelSlot(j) :
clusterAddSlot(server.cluster.myself,j);
redisAssert(retval == REDIS_OK); redisAssert(retval == REDIS_OK);
} }
} }
@ -1290,6 +1296,13 @@ void clusterCommand(redisClient *c) {
return; return;
} }
} }
/* If this node was the slot owner and the slot was marked as
* migrating, assigning the slot to another node will clear
* the migratig status. */
if (server.cluster.slots[slot] == server.cluster.myself &&
server.cluster.migrating_slots_to[slot])
server.cluster.migrating_slots_to[slot] = NULL;
clusterDelSlot(slot); clusterDelSlot(slot);
clusterAddSlot(n,slot); clusterAddSlot(n,slot);
} else { } else {