Fix module RdbLoad wrongly disable the AOF (#1001)
In RdbLoad, we disable AOF before emptyData and rdbLoad to prevent copy-on-write issues. After rdbLoad completes, AOF should be re-enabled, but the code incorrectly checks server.aof_state, which has been reset to AOF_OFF in stopAppendOnly. This leads to AOF not being re-enabled after being disabled. --------- Signed-off-by: Binbin <binloveplay1314@qq.com>
This commit is contained in:
parent
45ae39af04
commit
6d03409e01
@ -12928,6 +12928,9 @@ int VM_RdbLoad(ValkeyModuleCtx *ctx, ValkeyModuleRdbStream *stream, int flags) {
|
||||
disconnectSlaves();
|
||||
freeReplicationBacklog();
|
||||
|
||||
/* Stop and kill existing AOF rewriting fork as it is saving outdated data,
|
||||
* we will re-enable it after the rdbLoad. Also killing it will prevent COW
|
||||
* memory issue. */
|
||||
if (server.aof_state != AOF_OFF) stopAppendOnly();
|
||||
|
||||
/* Kill existing RDB fork as it is saving outdated data. Also killing it
|
||||
@ -12946,7 +12949,10 @@ int VM_RdbLoad(ValkeyModuleCtx *ctx, ValkeyModuleRdbStream *stream, int flags) {
|
||||
int ret = rdbLoad(stream->data.filename,NULL,RDBFLAGS_NONE);
|
||||
|
||||
if (server.current_client) unprotectClient(server.current_client);
|
||||
if (server.aof_state != AOF_OFF) startAppendOnly();
|
||||
|
||||
/* Here we need to decide whether to enable the AOF based on the aof_enabled,
|
||||
* since the previous stopAppendOnly sets aof_state to AOF_OFF. */
|
||||
if (server.aof_enabled) startAppendOnly();
|
||||
|
||||
if (ret != RDB_OK) {
|
||||
errno = (ret == RDB_NOT_EXIST) ? ENOENT : EIO;
|
||||
|
@ -80,6 +80,9 @@ start_server {tags {"modules"}} {
|
||||
fail "Can't find 'Killing AOF child' in recent log lines"
|
||||
}
|
||||
|
||||
# Verify that AOF is active.
|
||||
assert_equal 1 [s aof_enabled]
|
||||
|
||||
# Verify the value in the loaded rdb
|
||||
assert_equal v1 [r get k]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user