mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
Cluster: remove node from master slaves when it turns into a master.
Also, a few nearby comments improved.
This commit is contained in:
parent
44c92f5aeb
commit
004fbef847
@ -877,11 +877,13 @@ int clusterProcessPacket(clusterLink *link) {
|
|||||||
/* Update our info about the node */
|
/* Update our info about the node */
|
||||||
if (link->node) link->node->pong_received = time(NULL);
|
if (link->node) link->node->pong_received = time(NULL);
|
||||||
|
|
||||||
/* Update master/slave info */
|
/* Update master/slave state */
|
||||||
if (sender) {
|
if (sender) {
|
||||||
if (!memcmp(hdr->slaveof,REDIS_NODE_NULL_NAME,
|
if (!memcmp(hdr->slaveof,REDIS_NODE_NULL_NAME,
|
||||||
sizeof(hdr->slaveof)))
|
sizeof(hdr->slaveof)))
|
||||||
{
|
{
|
||||||
|
if (sender->slaveof)
|
||||||
|
clusterNodeRemoveSlave(sender->slaveof,sender);
|
||||||
sender->flags &= ~REDIS_NODE_SLAVE;
|
sender->flags &= ~REDIS_NODE_SLAVE;
|
||||||
sender->flags |= REDIS_NODE_MASTER;
|
sender->flags |= REDIS_NODE_MASTER;
|
||||||
sender->slaveof = NULL;
|
sender->slaveof = NULL;
|
||||||
@ -898,7 +900,9 @@ int clusterProcessPacket(clusterLink *link) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update our info about served slots. */
|
/* Update our info about served slots.
|
||||||
|
* Note: this MUST happen after we update the master/slave state
|
||||||
|
* so that REDIS_NODE_MASTER flag will be set. */
|
||||||
if (sender && sender->flags & REDIS_NODE_MASTER) {
|
if (sender && sender->flags & REDIS_NODE_MASTER) {
|
||||||
int changes, j;
|
int changes, j;
|
||||||
|
|
||||||
@ -909,7 +913,7 @@ int clusterProcessPacket(clusterLink *link) {
|
|||||||
if (bitmapTestBit(hdr->myslots,j)) {
|
if (bitmapTestBit(hdr->myslots,j)) {
|
||||||
/* If this slot was not served, or served by a node
|
/* If this slot was not served, or served by a node
|
||||||
* in FAIL state, update the table with the new node
|
* in FAIL state, update the table with the new node
|
||||||
* caliming to serve the slot. */
|
* claiming 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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user