Merge pull request #4976 from trevor211/fixDebugLoadaof

Critical: Fix server crash and data inconsistency in some cases.
This commit is contained in:
Salvatore Sanfilippo 2018-06-16 11:05:04 +02:00 committed by GitHub
commit 2e0ab4a807
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -348,7 +348,11 @@ NULL
serverLog(LL_WARNING,"DB reloaded by DEBUG RELOAD");
addReply(c,shared.ok);
} else if (!strcasecmp(c->argv[1]->ptr,"loadaof")) {
if (server.aof_state == AOF_ON) flushAppendOnlyFile(1);
if (server.aof_state == AOF_OFF) {
addReply(c, shared.err);
return;
}
flushAppendOnlyFile(1);
emptyDb(-1,EMPTYDB_NO_FLAGS,NULL);
if (loadAppendOnlyFile(server.aof_filename) != C_OK) {
addReply(c,shared.err);