startAppendOnly() fixed to set server.appendonly to 0 if the start failed.
This commit is contained in:
parent
fc96409f91
commit
af77acc310
@ -44,7 +44,6 @@ void stopAppendOnly(void) {
|
|||||||
/* Called when the user switches from "appendonly no" to "appendonly yes"
|
/* Called when the user switches from "appendonly no" to "appendonly yes"
|
||||||
* at runtime using the CONFIG command. */
|
* at runtime using the CONFIG command. */
|
||||||
int startAppendOnly(void) {
|
int startAppendOnly(void) {
|
||||||
server.appendonly = 1;
|
|
||||||
server.lastfsync = time(NULL);
|
server.lastfsync = time(NULL);
|
||||||
server.appendfd = open(server.appendfilename,O_WRONLY|O_APPEND|O_CREAT,0644);
|
server.appendfd = open(server.appendfilename,O_WRONLY|O_APPEND|O_CREAT,0644);
|
||||||
if (server.appendfd == -1) {
|
if (server.appendfd == -1) {
|
||||||
@ -52,13 +51,13 @@ int startAppendOnly(void) {
|
|||||||
return REDIS_ERR;
|
return REDIS_ERR;
|
||||||
}
|
}
|
||||||
if (rewriteAppendOnlyFileBackground() == REDIS_ERR) {
|
if (rewriteAppendOnlyFileBackground() == REDIS_ERR) {
|
||||||
server.appendonly = 0;
|
|
||||||
close(server.appendfd);
|
close(server.appendfd);
|
||||||
redisLog(REDIS_WARNING,"Redis needs to enable the AOF but can't trigger a background AOF rewrite operation. Check the above logs for more info about the error.");
|
redisLog(REDIS_WARNING,"Redis needs to enable the AOF but can't trigger a background AOF rewrite operation. Check the above logs for more info about the error.");
|
||||||
return REDIS_ERR;
|
return REDIS_ERR;
|
||||||
}
|
}
|
||||||
/* We correctly switched on AOF, now wait for the rerwite to be complete
|
/* We correctly switched on AOF, now wait for the rerwite to be complete
|
||||||
* in order to append data on disk. */
|
* in order to append data on disk. */
|
||||||
|
server.appendonly = 1;
|
||||||
server.aof_wait_rewrite = 1;
|
server.aof_wait_rewrite = 1;
|
||||||
return REDIS_OK;
|
return REDIS_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user