Skip to content

Commit

Permalink
Cluster: check that configEpoch never goes back.
Browse files Browse the repository at this point in the history
Since there are ways to alter the configEpoch outside of the failover
procedure (for exampel CLUSTER SET-CONFIG-EPOCH and via the configEpoch
collision resolution algorithm), make always sure, before replacing our
configEpoch with a new one, that it is greater than the current one.
  • Loading branch information
antirez committed Jun 7, 2014
1 parent a2c2ef7 commit 32d0a79
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -2516,7 +2516,8 @@ void clusterHandleSlaveFailover(void) {
}

/* 3) Update my configEpoch to the epoch of the election. */
myself->configEpoch = server.cluster->failover_auth_epoch;
if (myself->configEpoch < server.cluster->failover_auth_epoch)
myself->configEpoch = server.cluster->failover_auth_epoch;

/* 4) Update state and save config. */
clusterUpdateState();
Expand Down

0 comments on commit 32d0a79

Please sign in to comment.