Skip to content

Commit

Permalink
Trigger the election as soon as possible when doing a forced manual f…
Browse files Browse the repository at this point in the history
…ailover (valkey-io#1067)

In CLUSTER FAILOVER FORCE case, we will set mf_can_start to
1 and wait for a cron to trigger the election. We can also set a
CLUSTER_TODO_HANDLE_MANUALFAILOVER flag so that we
can start the election as soon as possible instead of waiting for
the cron, so that we won't have a 100ms delay (clusterCron).

Signed-off-by: Binbin <[email protected]>
Signed-off-by: naglera <[email protected]>
  • Loading branch information
enjoy-binbin authored and naglera committed Oct 10, 2024
1 parent 6372471 commit 6031623
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/cluster_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -6732,6 +6732,9 @@ int clusterCommandSpecial(client *c) {
* it without coordination. */
serverLog(LL_NOTICE, "Forced failover user request accepted (user request from '%s').", client);
server.cluster->mf_can_start = 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);
} else {
serverLog(LL_NOTICE, "Manual failover user request accepted (user request from '%s').", client);
clusterSendMFStart(myself->replicaof);
Expand Down

0 comments on commit 6031623

Please sign in to comment.