Merge pull request #7411 from tporadowski/inconsitent-sentinel-nosave

Inconsistent RDB saving when in Sentinel mode
This commit is contained in:
Salvatore Sanfilippo 2020-06-18 11:26:53 +02:00 committed by GitHub
commit ab4cc1e11b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View File

@ -963,14 +963,6 @@ void shutdownCommand(client *c) {
return; return;
} }
} }
/* 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).
*
* Also when in Sentinel mode clear the SAVE flag and force NOSAVE. */
if (server.loading || server.sentinel_mode)
flags = (flags & ~SHUTDOWN_SAVE) | SHUTDOWN_NOSAVE;
if (prepareForShutdown(flags) == C_OK) exit(0); if (prepareForShutdown(flags) == C_OK) exit(0);
addReplyError(c,"Errors trying to SHUTDOWN. Check logs."); addReplyError(c,"Errors trying to SHUTDOWN. Check logs.");
} }

View File

@ -3680,6 +3680,15 @@ void closeListeningSockets(int unlink_unix_socket) {
} }
int prepareForShutdown(int flags) { int prepareForShutdown(int flags) {
/* 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).
*
* Also when in Sentinel mode clear the SAVE flag and force NOSAVE. */
if (server.loading || server.sentinel_mode)
flags = (flags & ~SHUTDOWN_SAVE) | SHUTDOWN_NOSAVE;
int save = flags & SHUTDOWN_SAVE; int save = flags & SHUTDOWN_SAVE;
int nosave = flags & SHUTDOWN_NOSAVE; int nosave = flags & SHUTDOWN_NOSAVE;