Commit 07b63227 authored by antirez's avatar antirez
Browse files

Cluster: more correct update of slots state when PONG is received.

parent c6da9d9f
...@@ -655,8 +655,7 @@ int clusterProcessPacket(clusterLink *link) { ...@@ -655,8 +655,7 @@ int clusterProcessPacket(clusterLink *link) {
} }
} }
/* Update our info about served slots if this new node is serving /* Update our info about served slots. */
* slots that are not served from our point of view. */
if (sender && sender->flags & REDIS_NODE_MASTER) { if (sender && sender->flags & REDIS_NODE_MASTER) {
int newslots, j; int newslots, j;
...@@ -666,6 +665,9 @@ int clusterProcessPacket(clusterLink *link) { ...@@ -666,6 +665,9 @@ int clusterProcessPacket(clusterLink *link) {
if (newslots) { if (newslots) {
for (j = 0; j < REDIS_CLUSTER_SLOTS; j++) { for (j = 0; j < REDIS_CLUSTER_SLOTS; j++) {
if (clusterNodeGetSlotBit(sender,j)) { if (clusterNodeGetSlotBit(sender,j)) {
/* If this slot was not served, or served by a node
* in FAIL state, update the table with the new node
* caliming to serve the slot. */
if (server.cluster->slots[j] == sender) continue; if (server.cluster->slots[j] == sender) continue;
if (server.cluster->slots[j] == NULL || if (server.cluster->slots[j] == NULL ||
server.cluster->slots[j]->flags & REDIS_NODE_FAIL) server.cluster->slots[j]->flags & REDIS_NODE_FAIL)
...@@ -674,6 +676,16 @@ int clusterProcessPacket(clusterLink *link) { ...@@ -674,6 +676,16 @@ int clusterProcessPacket(clusterLink *link) {
clusterAddSlot(sender,j); clusterAddSlot(sender,j);
update_state = update_config = 1; update_state = update_config = 1;
} }
} else {
/* If this slot was served by this node, but it is
* no longer claiming it, del it from the table. */
if (server.cluster->slots[j] == sender) {
/* Set the bit again before calling
* clusterDelSlot() or the assert will fail. */
clusterNodeSetSlotBit(sender,j);
clusterDelSlot(j);
update_state = update_config = 1;
}
} }
} }
} }
......
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