From 8c1bc8e8659d29d98315e3d8d6cc482667afc001 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 20 Mar 2013 11:50:55 +0100 Subject: [PATCH] Cluster: clear the PROMOTED slave directly into clusterSetMaster(). This way we make sure every time a master is turned into a replica the flag will be cleared. --- src/cluster.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cluster.c b/src/cluster.c index 34c5627f4..e5e3968f2 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -1849,6 +1849,9 @@ void clusterSetMaster(clusterNode *n) { myself->flags &= ~REDIS_NODE_MASTER; myself->flags |= REDIS_NODE_SLAVE; } + /* Clear the promoted flag anyway if we are a slave, to ensure it will + * be set only when the node turns into a master because of fail over. */ + myself->flags &= ~REDIS_NODE_PROMOTED; myself->slaveof = n; replicationSetMaster(n->ip, n->port); } @@ -2247,7 +2250,6 @@ void clusterCommand(redisClient *c) { } /* Set the master. */ - server.cluster->myself->flags &= ~REDIS_NODE_PROMOTED; clusterSetMaster(n); clusterUpdateState(); clusterSaveConfigOrDie(); -- GitLab