Skip to content

Commit

Permalink
Avoid shard id update of replica if not matching with primary shard id
Browse files Browse the repository at this point in the history
Signed-off-by: Harkrishn Patro <harkrisp@amazon.com>
  • Loading branch information
hpatro committed May 29, 2024
1 parent a0aebb6 commit 7cabc57
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/cluster_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,12 @@ static void updateAnnouncedHumanNodename(clusterNode *node, char *new) {


static void updateShardId(clusterNode *node, const char *shard_id) {
/* Shard id update of replica independently will corrupt the config file. */
if (shard_id && nodeIsSlave(node) && memcmp(clusterNodeGetMaster(node)->shard_id, shard_id, CLUSTER_NAMELEN) != 0) {
serverLog(LL_NOTICE, "Shard id %.40s update request for node id %.40s diverges from existing primary shard id %.40s, rejecting!", shard_id, node->name, clusterNodeGetMaster(node)->shard_id);
return;
}

if (shard_id && memcmp(node->shard_id, shard_id, CLUSTER_NAMELEN) != 0) {
clusterRemoveNodeFromShard(node);
memcpy(node->shard_id, shard_id, CLUSTER_NAMELEN);
Expand Down

0 comments on commit 7cabc57

Please sign in to comment.