diff --git a/src/cluster.c b/src/cluster.c index e4b2d0f53d..c985d0b18b 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -1687,6 +1687,7 @@ void clusterRenameNode(clusterNode *node, char *newname) { serverAssert(retval == DICT_OK); memcpy(node->name, newname, CLUSTER_NAMELEN); clusterAddNode(node); + clusterAddNodeToShard(node->shard_id, node); } void clusterAddNodeToShard(const char *shard_id, clusterNode *node) { @@ -2234,6 +2235,7 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) { node->tls_port = msg_tls_port; node->cport = ntohs(g->cport); clusterAddNode(node); + clusterAddNodeToShard(node->shard_id, node); } } @@ -3036,6 +3038,10 @@ int clusterProcessPacket(clusterLink *link) { clusterNodeAddSlave(master,sender); sender->slaveof = master; + /* Update the shard_id when a replica is connected to its + * primary in the very first time. */ + updateShardId(sender, master->shard_id); + /* Update config. */ clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG); }