summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-05-12 16:12:12 +0200
committerantirez <antirez@gmail.com>2014-05-20 17:45:49 +0200
commitb5cdd42bf3080bb00c5accde2d0a8f10e91d3729 (patch)
tree629945d3884250b3c19d80f310d050c3304798cc
parent26eb7ec7312eb5aa893252de67ccd3748f02f130 (diff)
downloadredis-b5cdd42bf3080bb00c5accde2d0a8f10e91d3729.tar.gz
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.
-rw-r--r--src/cluster.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/cluster.c b/src/cluster.c
index d9d904199..70ad7ab7c 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)
{