summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2013-03-20 11:32:35 +0100
committerantirez <antirez@gmail.com>2013-03-20 11:32:35 +0100
commite006407fd08bb2b0a7f0aac703e367786ae85168 (patch)
tree7cdf19e5e47680aea9328d376723340aa541c15d /src
parent506f9a42b07649d793b9c3245da14aa0fecd2d59 (diff)
downloadredis-e006407fd08bb2b0a7f0aac703e367786ae85168.tar.gz
Cluster: master node must clear its hash slots when turning into a slave.
When a master turns into a slave after a failover event, make sure to clear the assigned slots before setting up the replication, as a slave should never claim slots in an explicit way, but just take over the master slots when replacing its master.
Diffstat (limited to 'src')
-rw-r--r--src/cluster.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/cluster.c b/src/cluster.c
index f26cc98c1..34c5627f4 100644
--- a/src/cluster.c
+++ b/src/cluster.c
@@ -907,6 +907,7 @@ int clusterProcessPacket(clusterLink *link) {
oldmaster == server.cluster->myself)
{
redisLog(REDIS_WARNING,"One of my slaves took my place. Reconfiguring myself as a replica of %.40s", sender->name);
+ clusterDelNodeSlots(server.cluster->myself);
clusterSetMaster(sender);
}
@@ -1836,11 +1837,13 @@ int verifyClusterConfigWithData(void) {
* SLAVE nodes handling
* -------------------------------------------------------------------------- */
-/* Set the specified node 'n' as master. */
+/* Set the specified node 'n' as master. Setup the node as a slave if
+ * needed. */
void clusterSetMaster(clusterNode *n) {
clusterNode *myself = server.cluster->myself;
redisAssert(n != myself);
+ redisAssert(myself->numslots == 0);
if (myself->flags & REDIS_NODE_MASTER) {
myself->flags &= ~REDIS_NODE_MASTER;