From 519eb2a31edabc613ad8caf901ef2fd7a945dd38 Mon Sep 17 00:00:00 2001 From: Binbin Date: Mon, 21 Oct 2024 11:16:25 +0800 Subject: [PATCH] removing mf_is_primary_failover Signed-off-by: Binbin --- src/cluster_legacy.c | 21 +++++---------------- src/cluster_legacy.h | 1 - 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/src/cluster_legacy.c b/src/cluster_legacy.c index 7ab0613f8a..3a3be879f8 100644 --- a/src/cluster_legacy.c +++ b/src/cluster_legacy.c @@ -3502,14 +3502,10 @@ int clusterProcessPacket(clusterLink *link) { * a non zero number of slots, and its currentEpoch is greater or * equal to epoch where this node started the election. */ if (clusterNodeIsVotingPrimary(sender) && sender_claimed_current_epoch >= server.cluster->failover_auth_epoch) { - /* todo: see if this needed. */ - /* My primary has already voted for me, so don't count it anymore. */ - if (!(sender == myself->replicaof && server.cluster->mf_is_primary_failover)) { - server.cluster->failover_auth_count++; - /* Maybe we reached a quorum here, set a flag to make sure - * we check ASAP. */ - clusterDoBeforeSleep(CLUSTER_TODO_HANDLE_FAILOVER); - } + server.cluster->failover_auth_count++; + /* Maybe we reached a quorum here, set a flag to make sure + * we check ASAP. */ + clusterDoBeforeSleep(CLUSTER_TODO_HANDLE_FAILOVER); } } else if (type == CLUSTERMSG_TYPE_MFSTART) { /* This message is acceptable only if I'm a primary and the sender @@ -4592,11 +4588,7 @@ void clusterHandleReplicaFailover(void) { if (server.cluster->mf_end) { server.cluster->failover_auth_time = mstime(); server.cluster->failover_auth_rank = 0; - /* todo: see if this is needed. */ - /* This is a failover triggered by my primary, let's counts its vote. */ - if (server.cluster->mf_is_primary_failover) { - server.cluster->failover_auth_count++; - } + server.cluster->failover_auth_count++; clusterDoBeforeSleep(CLUSTER_TODO_HANDLE_FAILOVER); } serverLog(LL_NOTICE, @@ -4821,7 +4813,6 @@ void resetManualFailover(void) { } server.cluster->mf_end = 0; /* No manual failover in progress. */ server.cluster->mf_can_start = 0; - server.cluster->mf_is_primary_failover = 0; server.cluster->mf_replica = NULL; server.cluster->mf_primary_offset = -1; } @@ -4850,7 +4841,6 @@ void clusterHandleManualFailover(void) { /* Our replication offset matches the primary replication offset * announced after clients were paused. We can start the failover. */ server.cluster->mf_can_start = 1; - server.cluster->mf_is_primary_failover = 0; serverLog(LL_NOTICE, "All primary replication stream processed, " "manual failover can start."); clusterDoBeforeSleep(CLUSTER_TODO_HANDLE_FAILOVER); @@ -6743,7 +6733,6 @@ int clusterCommandSpecial(client *c) { serverLog(LL_NOTICE, "Forced failover user request accepted (user request from '%s').", client); } server.cluster->mf_can_start = 1; - server.cluster->mf_is_primary_failover = 1; /* We can start a manual failover as soon as possible, setting a flag * here so that we don't need to waiting for the cron to kick in. */ clusterDoBeforeSleep(CLUSTER_TODO_HANDLE_MANUALFAILOVER); diff --git a/src/cluster_legacy.h b/src/cluster_legacy.h index c97ec2df7f..5280644e6e 100644 --- a/src/cluster_legacy.h +++ b/src/cluster_legacy.h @@ -393,7 +393,6 @@ struct clusterState { or -1 if still not received. */ int mf_can_start; /* If non-zero signal that the manual failover can start requesting primary vote. */ - int mf_is_primary_failover; /* The manual failover was triggered by my primary. */ /* The following fields are used by primaries to take state on elections. */ uint64_t lastVoteEpoch; /* Epoch of the last vote granted. */ int todo_before_sleep; /* Things to do in clusterBeforeSleep(). */