From 1d804400f5cac5847f7bd4b04fb8e7027f2fdd3d Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 30 Jan 2014 18:23:31 +0100 Subject: [PATCH] Cluster: perform orphaned masters check before continue statements. The check was placed in a way that conflicted with the continue statements used by the node hearth beat code later that needs to skip the current node sometimes. Moved at the start of the function so that's always executed. --- src/cluster.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/cluster.c b/src/cluster.c index 149faf047..1ee5d689a 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -2312,6 +2312,17 @@ void clusterCron(void) { (REDIS_NODE_MYSELF|REDIS_NODE_NOADDR|REDIS_NODE_HANDSHAKE)) continue; + /* Orphaned master check, useful only if the current instance + * is a slave that may migrate to another master. */ + if (nodeIsSlave(myself) && nodeIsMaster(node) && !nodeFailed(node)) { + int okslaves = clusterCountNonFailingSlaves(node); + + if (okslaves == 0) orphaned_masters++; + if (okslaves > max_slaves) max_slaves = okslaves; + if (nodeIsSlave(myself) && myself->slaveof == node) + this_slaves = okslaves; + } + /* If we are waiting for the PONG more than half the cluster * timeout, reconnect the link: maybe there is a connection * issue even if the node is alive. */ @@ -2357,17 +2368,6 @@ void clusterCron(void) { update_state = 1; } } - - /* Orphaned master check, useful only if the current instance - * is a slave that may migrate to another master. */ - if (nodeIsSlave(myself) && nodeIsMaster(node) && !nodeFailed(node)) { - int okslaves = clusterCountNonFailingSlaves(node); - - if (okslaves == 0) orphaned_masters++; - if (okslaves > max_slaves) max_slaves = okslaves; - if (nodeIsSlave(myself) && myself->slaveof == node) - this_slaves = okslaves; - } } dictReleaseIterator(di);