Cluster: fix slave data age computation when master is still connected.

This commit is contained in:
antirez 2013-10-07 16:07:13 +02:00
parent 2c3301b9f5
commit f7d6ad4366

View File

@ -1607,11 +1607,18 @@ void clusterSendFailoverAuthIfNeeded(clusterNode *node, clusterMsg *request) {
* 3) Perform the failover informing all the other nodes. * 3) Perform the failover informing all the other nodes.
*/ */
void clusterHandleSlaveFailover(void) { void clusterHandleSlaveFailover(void) {
time_t data_age = server.unixtime - server.repl_down_since; time_t data_age;
mstime_t auth_age = mstime() - server.cluster->failover_auth_time; mstime_t auth_age = mstime() - server.cluster->failover_auth_time;
int needed_quorum = (server.cluster->size / 2) + 1; int needed_quorum = (server.cluster->size / 2) + 1;
int j; int j;
/* Set data_age to the number of seconds we are disconnected from the master. */
if (server.repl_state == REDIS_REPL_CONNECTED) {
data_age = server.unixtime - server.master->lastinteraction;
} else {
data_age = server.unixtime - server.repl_down_since;
}
/* Pre conditions to run the function: /* Pre conditions to run the function:
* 1) We are a slave. * 1) We are a slave.
* 2) Our master is flagged as FAIL. * 2) Our master is flagged as FAIL.