mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
Cluster: improve crash-recovery safety after failover auth vote.
Add AE_BARRIER to the writable event loop so that slaves requesting votes can't be served before we re-enter the event loop in the next iteration, so clusterBeforeSleep() will fsync to disk in time. Also add the call to explicitly fsync, given that we modified the last vote epoch variable.
This commit is contained in:
parent
548e478e40
commit
533d0e0375
@ -2156,7 +2156,7 @@ void clusterReadHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
|
|||||||
* from event handlers that will do stuff with the same link later. */
|
* from event handlers that will do stuff with the same link later. */
|
||||||
void clusterSendMessage(clusterLink *link, unsigned char *msg, size_t msglen) {
|
void clusterSendMessage(clusterLink *link, unsigned char *msg, size_t msglen) {
|
||||||
if (sdslen(link->sndbuf) == 0 && msglen != 0)
|
if (sdslen(link->sndbuf) == 0 && msglen != 0)
|
||||||
aeCreateFileEvent(server.el,link->fd,AE_WRITABLE,
|
aeCreateFileEvent(server.el,link->fd,AE_WRITABLE|AE_BARRIER,
|
||||||
clusterWriteHandler,link);
|
clusterWriteHandler,link);
|
||||||
|
|
||||||
link->sndbuf = sdscatlen(link->sndbuf, msg, msglen);
|
link->sndbuf = sdscatlen(link->sndbuf, msg, msglen);
|
||||||
@ -2691,9 +2691,10 @@ void clusterSendFailoverAuthIfNeeded(clusterNode *node, clusterMsg *request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* We can vote for this slave. */
|
/* We can vote for this slave. */
|
||||||
clusterSendFailoverAuth(node);
|
|
||||||
server.cluster->lastVoteEpoch = server.cluster->currentEpoch;
|
server.cluster->lastVoteEpoch = server.cluster->currentEpoch;
|
||||||
node->slaveof->voted_time = mstime();
|
node->slaveof->voted_time = mstime();
|
||||||
|
clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG|CLUSTER_TODO_FSYNC_CONFIG);
|
||||||
|
clusterSendFailoverAuth(node);
|
||||||
serverLog(LL_WARNING, "Failover auth granted to %.40s for epoch %llu",
|
serverLog(LL_WARNING, "Failover auth granted to %.40s for epoch %llu",
|
||||||
node->name, (unsigned long long) server.cluster->currentEpoch);
|
node->name, (unsigned long long) server.cluster->currentEpoch);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user