mirror of
https://github.com/fluencelabs/redis
synced 2025-03-18 16:40:50 +00:00
Cluster: clear todo_before_sleep flags when executing actions.
Thanks to this change, when there is some code like: clusterDoBeforeSleep(CLUSTER_TODO_UPDATE_STATE|...); ... and later before returning to the event loop ... clusterUpdateState(); The clusterUpdateState() function will clar the flag and will not be repeated in the clusterBeforeSleep() function. This especially important for config save/fsync flags which are slow to execute and not a good idea to repeat without a good reason. This is implemented for all the CLUSTER_TODO flags.
This commit is contained in:
parent
7b87cda70e
commit
8c6e92c3bc
@ -306,6 +306,8 @@ int clusterSaveConfig(int do_fsync) {
|
||||
struct stat sb;
|
||||
int fd;
|
||||
|
||||
server.cluster->todo_before_sleep &= ~CLUSTER_TODO_SAVE_CONFIG;
|
||||
|
||||
/* Get the nodes description and concatenate our "vars" directive to
|
||||
* save currentEpoch and lastVoteEpoch. */
|
||||
ci = clusterGenNodesDescription(REDIS_NODE_HANDSHAKE);
|
||||
@ -325,7 +327,10 @@ int clusterSaveConfig(int do_fsync) {
|
||||
}
|
||||
}
|
||||
if (write(fd,ci,sdslen(ci)) != (ssize_t)sdslen(ci)) goto err;
|
||||
if (do_fsync) fsync(fd);
|
||||
if (do_fsync) {
|
||||
server.cluster->todo_before_sleep &= ~CLUSTER_TODO_FSYNC_CONFIG;
|
||||
fsync(fd);
|
||||
}
|
||||
|
||||
/* Truncate the file if needed to remove the final \n padding that
|
||||
* is just garbage. */
|
||||
@ -2367,6 +2372,8 @@ void clusterHandleSlaveFailover(void) {
|
||||
int j;
|
||||
mstime_t auth_timeout, auth_retry_time;
|
||||
|
||||
server.cluster->todo_before_sleep &= ~CLUSTER_TODO_HANDLE_FAILOVER;
|
||||
|
||||
/* Compute the failover timeout (the max time we have to send votes
|
||||
* and wait for replies), and the failover retry time (the time to wait
|
||||
* before waiting again.
|
||||
@ -2944,7 +2951,8 @@ void clusterBeforeSleep(void) {
|
||||
clusterSaveConfigOrDie(fsync);
|
||||
}
|
||||
|
||||
/* Reset our flags. */
|
||||
/* Reset our flags (not strictly needed since every single function
|
||||
* called for flags set should be able to clear its flag). */
|
||||
server.cluster->todo_before_sleep = 0;
|
||||
}
|
||||
|
||||
@ -3061,6 +3069,8 @@ void clusterUpdateState(void) {
|
||||
static mstime_t among_minority_time;
|
||||
static mstime_t first_call_time = 0;
|
||||
|
||||
server.cluster->todo_before_sleep &= ~CLUSTER_TODO_UPDATE_STATE;
|
||||
|
||||
/* If this is a master node, wait some time before turning the state
|
||||
* into OK, since it is not a good idea to rejoin the cluster as a writable
|
||||
* master, after a reboot, without giving the cluster a chance to
|
||||
|
Loading…
x
Reference in New Issue
Block a user