From 2ecb5edf3454e3752a428e50b6ee068e357c7fae Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 20 Mar 2015 09:46:10 +0100 Subject: [PATCH] Cluster: move clusterBeforeSleep() call before unblocked clients processing. Related to issue #2288. --- src/redis.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/redis.c b/src/redis.c index 75975a498..48e7f24ea 100644 --- a/src/redis.c +++ b/src/redis.c @@ -1260,6 +1260,12 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) { void beforeSleep(struct aeEventLoop *eventLoop) { REDIS_NOTUSED(eventLoop); + /* Call the Redis Cluster before sleep function. Note that this function + * may change the state of Redis Cluster (frok ok to fail or vice versa), + * so it's a good idea to call it before serving the unblocked clients + * later in this function. */ + if (server.cluster_enabled) clusterBeforeSleep(); + /* Run a fast expire cycle (the called function will return * ASAP if a fast cycle is not needed). */ if (server.active_expire_enabled && server.masterhost == NULL) @@ -1291,9 +1297,6 @@ void beforeSleep(struct aeEventLoop *eventLoop) { /* Write the AOF buffer on disk */ flushAppendOnlyFile(0); - - /* Call the Redis Cluster before sleep function. */ - if (server.cluster_enabled) clusterBeforeSleep(); } /* =========================== Server initialization ======================== */