Skip to content

Commit

Permalink
Cluster: bypass data_age check for manual failovers.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
antirez committed May 12, 2014
1 parent b252fab commit 005f564
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/cluster.c
Expand Up @@ -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. */
Expand All @@ -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. */
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 005f564

Please sign in to comment.