From 005f564eb3e7c5675dfce0a250c6d0b30c69932c Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 12 May 2014 16:12:12 +0200 Subject: [PATCH] Cluster: bypass data_age check for manual failovers. Automatic failovers only happen in Redis Cluster if the slave trying to be elected was disconnected from its master for no more than 10 times the node-timeout value. However there should be no such a check for manual failovers, since these are initiated by the sysadmin that, in theory, knows what she is doing when a slave is selected to be promoted. --- src/cluster.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/cluster.c b/src/cluster.c index d9d90419..70ad7ab7 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -2305,7 +2305,8 @@ void clusterHandleSlaveFailover(void) { if (auth_timeout < 2000) auth_timeout = 2000; auth_retry_time = auth_timeout*2; - /* Pre conditions to run the function: + /* Pre conditions to run the function, that must be met both in case + * of an automatic or manual failover: * 1) We are a slave. * 2) Our master is flagged as FAIL, or this is a manual failover. * 3) It is serving slots. */ @@ -2330,11 +2331,15 @@ void clusterHandleSlaveFailover(void) { /* Check if our data is recent enough. For now we just use a fixed * constant of ten times the node timeout since the cluster should - * react much faster to a master down. */ + * react much faster to a master down. + * + * Check bypassed for manual failovers. */ if (data_age > (server.repl_ping_slave_period * 1000) + (server.cluster_node_timeout * REDIS_CLUSTER_SLAVE_VALIDITY_MULT)) - return; + { + if (!manual_failover) return; + } /* If the previous failover attempt timedout and the retry time has * elapsed, we can setup a new one. */ @@ -2370,7 +2375,9 @@ void clusterHandleSlaveFailover(void) { /* It is possible that we received more updated offsets from other * slaves for the same master since we computed our election delay. - * Update the delay if our rank changed. */ + * Update the delay if our rank changed. + * + * Not performed if this is a manual failover. */ if (server.cluster->failover_auth_sent == 0 && server.cluster->mf_end == 0) {