Skip to content

Commit

Permalink
removing mf_is_primary_failover
Browse files Browse the repository at this point in the history
Signed-off-by: Binbin <[email protected]>
  • Loading branch information
enjoy-binbin committed Oct 21, 2024
1 parent 594fd5a commit 519eb2a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
21 changes: 5 additions & 16 deletions src/cluster_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/cluster_legacy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(). */
Expand Down

0 comments on commit 519eb2a

Please sign in to comment.