提交 596b71f4 编写于 作者: E Enrico Giordani

[Fix] Disable replication if persistence is not available.

Replication (including diskless replication) requires persistence to be
available. This fix prevents a crash and returns "ERR unknown command" to
the slave.
上级 607d6f92
......@@ -588,21 +588,37 @@ void loadServerConfigFromString(char *config) {
// ignore. This is taken care of in the win32_service code.
} else if (!strcasecmp(argv[0], "persistence-available")) {
if (strcasecmp(argv[1], "no") == 0) {
//remove BGSAVE and BGREWRITEAOF when persistence is disabled
// remove BGSAVE, BGREWRITEAOF and replication commands
// when persistence is disabled
int retval;
sds bgsave;
sds bgrewriteaof;
sds replconf;
sds psync;
sds sync;
bgsave = sdsnew("bgsave");
bgrewriteaof = sdsnew("bgrewriteaof");
replconf = sdsnew("replconf");
psync = sdsnew("psync");
sync = sdsnew("sync");
retval = dictDelete(server.commands, bgsave);
redisAssert(retval == DICT_OK);
retval = dictDelete(server.commands, bgrewriteaof);
redisAssert(retval == DICT_OK);
retval = dictDelete(server.commands, replconf);
redisAssert(retval == DICT_OK);
retval = dictDelete(server.commands, psync);
redisAssert(retval == DICT_OK);
retval = dictDelete(server.commands, sync);
redisAssert(retval == DICT_OK);
sdsfree(bgsave);
sdsfree(bgrewriteaof);
sdsfree(replconf);
sdsfree(psync);
sdsfree(sync);
}
#endif
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册