From 59ad6ac5feac4f6760144861b723a51383a0f19b Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 21 Jan 2015 15:55:53 +0100 Subject: [PATCH] Cluster: set the slaves->slaveof filed to NULL when master is freed. Related to issue #2289. --- src/cluster.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/cluster.c b/src/cluster.c index ec6901e8..5135cdaa 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -821,6 +821,14 @@ int clusterCountNonFailingSlaves(clusterNode *n) { void freeClusterNode(clusterNode *n) { sds nodename; + int j; + + /* If the node is a master with associated slaves, we have to set + * all the slaves->slaveof fields to NULL (unknown). */ + if (nodeIsMaster(n)) { + for (j = 0; j < n->numslaves; j++) + n->slaves[j]->slaveof = NULL; + } nodename = sdsnewlen(n->name, REDIS_CLUSTER_NAMELEN); redisAssert(dictDelete(server.cluster->nodes,nodename) == DICT_OK);