diff --git a/src/db.c b/src/db.c index a5088195ba39d3e283bb76317a800179b6107c95..41e95b6ba5e2d98f7c45fe2ece37703e30145959 100644 --- a/src/db.c +++ b/src/db.c @@ -605,11 +605,13 @@ void shutdownCommand(redisClient *c) { return; } } - /* SHUTDOWN can be called even while the server is in "loading" state. - * When this happens we need to make sure no attempt is performed to save + /* When SHUTDOWN is called while the server is loading a dataset in + * memory we need to make sure no attempt is performed to save * the dataset on shutdown (otherwise it could overwrite the current DB - * with half-read data). */ - if (server.loading) + * with half-read data). + * + * 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; if (prepareForShutdown(flags) == REDIS_OK) exit(0); addReplyError(c,"Errors trying to SHUTDOWN. Check logs."); diff --git a/src/redis.c b/src/redis.c index 7db028566b6f5483f37821397750a77fa9b504f2..437e76959025a3926149f7138202d1f97935d966 100644 --- a/src/redis.c +++ b/src/redis.c @@ -2190,7 +2190,8 @@ int prepareForShutdown(int flags) { } /* Close the listening sockets. Apparently this allows faster restarts. */ 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; } diff --git a/src/sentinel.c b/src/sentinel.c index d5d4d928e7bf18b85f2f532a85942928226853c3..fb8b220a8b8c221012fca20654d22a4cf6c79e73 100644 --- a/src/sentinel.c +++ b/src/sentinel.c @@ -377,7 +377,8 @@ struct redisCommand sentinelcmds[] = { {"unsubscribe",unsubscribeCommand,-1,"",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}, - {"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