diff --git a/src/cluster_legacy.c b/src/cluster_legacy.c index 6ea8eb2e67..50a8ffca38 100644 --- a/src/cluster_legacy.c +++ b/src/cluster_legacy.c @@ -3149,7 +3149,8 @@ int clusterProcessPacket(clusterLink *link) { sender->configEpoch = sender_claimed_config_epoch; clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG | CLUSTER_TODO_FSYNC_CONFIG); - if (server.cluster->failover_auth_time && sender->configEpoch >= server.cluster->failover_auth_epoch) { + if (server.cluster->failover_auth_time && server.cluster->failover_auth_sent && + sender->configEpoch >= server.cluster->failover_auth_epoch) { /* Another node has claimed an epoch greater than or equal to ours. * If we have an ongoing election, reset it because we cannot win * with an epoch smaller than or equal to the incoming claim. This diff --git a/tests/unit/cluster/failover2.tcl b/tests/unit/cluster/failover2.tcl index 21c4f4a678..9262049e4e 100644 --- a/tests/unit/cluster/failover2.tcl +++ b/tests/unit/cluster/failover2.tcl @@ -86,6 +86,11 @@ start_cluster 7 3 {tags {external:skip cluster} overrides {cluster-ping-interval fail "No failover detected" } + # Make sure there is no false epoch 0. + verify_no_log_message -7 "*Failover election in progress for epoch 0*" 0 + verify_no_log_message -8 "*Failover election in progress for epoch 0*" 0 + verify_no_log_message -9 "*Failover election in progress for epoch 0*" 0 + # Make sure there is no failover timeout. verify_no_log_message -7 "*Failover attempt expired*" 0 verify_no_log_message -8 "*Failover attempt expired*" 0