1
0
mirror of https://github.com/fluencelabs/redis synced 2025-04-05 01:01:04 +00:00

Sentinel: allow SHUTDOWN command in Sentinel mode.

This commit is contained in:
antirez 2014-02-07 11:22:24 +01:00
parent 970de3e9c0
commit 2d6eb68993
3 changed files with 10 additions and 6 deletions

@ -605,11 +605,13 @@ void shutdownCommand(redisClient *c) {
return; return;
} }
} }
/* SHUTDOWN can be called even while the server is in "loading" state. /* When SHUTDOWN is called while the server is loading a dataset in
* When this happens we need to make sure no attempt is performed to save * memory we need to make sure no attempt is performed to save
* the dataset on shutdown (otherwise it could overwrite the current DB * the dataset on shutdown (otherwise it could overwrite the current DB
* with half-read data). */ * with half-read data).
if (server.loading) *
* Also when in Sentinel mode clear the SAVE flag and force NOSAVE. */
if (server.loading || server.sentinel_mode)
flags = (flags & ~REDIS_SHUTDOWN_SAVE) | REDIS_SHUTDOWN_NOSAVE; flags = (flags & ~REDIS_SHUTDOWN_SAVE) | REDIS_SHUTDOWN_NOSAVE;
if (prepareForShutdown(flags) == REDIS_OK) exit(0); if (prepareForShutdown(flags) == REDIS_OK) exit(0);
addReplyError(c,"Errors trying to SHUTDOWN. Check logs."); addReplyError(c,"Errors trying to SHUTDOWN. Check logs.");

@ -2190,7 +2190,8 @@ int prepareForShutdown(int flags) {
} }
/* Close the listening sockets. Apparently this allows faster restarts. */ /* Close the listening sockets. Apparently this allows faster restarts. */
closeListeningSockets(1); closeListeningSockets(1);
redisLog(REDIS_WARNING,"Redis is now ready to exit, bye bye..."); redisLog(REDIS_WARNING,"%s is now ready to exit, bye bye...",
server.sentinel_mode ? "Sentinel" : "Redis");
return REDIS_OK; return REDIS_OK;
} }

@ -377,7 +377,8 @@ struct redisCommand sentinelcmds[] = {
{"unsubscribe",unsubscribeCommand,-1,"",0,NULL,0,0,0,0,0}, {"unsubscribe",unsubscribeCommand,-1,"",0,NULL,0,0,0,0,0},
{"psubscribe",psubscribeCommand,-2,"",0,NULL,0,0,0,0,0}, {"psubscribe",psubscribeCommand,-2,"",0,NULL,0,0,0,0,0},
{"punsubscribe",punsubscribeCommand,-1,"",0,NULL,0,0,0,0,0}, {"punsubscribe",punsubscribeCommand,-1,"",0,NULL,0,0,0,0,0},
{"info",sentinelInfoCommand,-1,"",0,NULL,0,0,0,0,0} {"info",sentinelInfoCommand,-1,"",0,NULL,0,0,0,0,0},
{"shutdown",shutdownCommand,-1,"",0,NULL,0,0,0,0,0}
}; };
/* This function overwrites a few normal Redis config default with Sentinel /* This function overwrites a few normal Redis config default with Sentinel