diff options
author | chenyang8094 <chenyang8094@users.noreply.github.com> | 2022-01-13 14:49:26 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-13 08:49:26 +0200 |
commit | e9bff7978a4e4b5cc7ab958715d1a6214dc68919 (patch) | |
tree | d4be16b9cd4fe3b85375bf5c78a754c5d08f6373 /tests/integration/aof-multi-part.tcl | |
parent | 20c33fe6a8fce2edb3e4158bc10bde2c3740a25b (diff) | |
download | redis-e9bff7978a4e4b5cc7ab958715d1a6214dc68919.tar.gz |
Always create base AOF file when redis start from empty. (#10102)
Force create a BASE file (use a foreground `rewriteAppendOnlyFile`) when redis starts from an
empty data set and `appendonly` is yes.
The reasoning is that normally, after redis is running for some time, and the AOF has gone though
a few rewrites, there's always a base rdb file. and the scenario where the base file is missing, is
kinda rare (happens only at empty startup), so this change normalizes it.
But more importantly, there are or could be some complex modules that are started with some
configuration, when they create persistence they write that configuration to RDB AUX fields, so
that can can always know with which configuration the persistence file they're loading was
created (could be critical). there is (was) one scenario in which they could load their persisted data,
and that configuration was missing, and this change fixes it.
Add a new module event: REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_AOF_START, similar to
REDISMODULE_SUBEVENT_PERSISTENCE_AOF_START which is async.
Co-authored-by: Oran Agra <oran@redislabs.com>
Diffstat (limited to 'tests/integration/aof-multi-part.tcl')
-rw-r--r-- | tests/integration/aof-multi-part.tcl | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/tests/integration/aof-multi-part.tcl b/tests/integration/aof-multi-part.tcl index b5b2f3ff9..ac5ed4f33 100644 --- a/tests/integration/aof-multi-part.tcl +++ b/tests/integration/aof-multi-part.tcl @@ -687,7 +687,7 @@ tags {"external:skip"} { waitForBgrewriteaof $redis assert_aof_manifest_content $aof_manifest_name { - {file " file seq .aof .1.base.rdb" seq 1 type b} + {file " file seq .aof .2.base.rdb" seq 2 type b} {file " file seq .aof .2.incr.aof" seq 2 type i} } @@ -696,6 +696,54 @@ tags {"external:skip"} { set d2 [$redis debug digest] assert {$d1 eq $d2} } + + clean_aof_persistence $aof_dirpath + } + + test {Multi Part AOF can create BASE (RDB format) when redis starts from empty} { + start_server_aof [list dir $server_path] { + set client [redis [dict get $srv host] [dict get $srv port] 0 $::tls] + wait_done_loading $client + + assert_equal 1 [check_file_exist $aof_dirpath "${aof_basename}.1${::base_aof_sufix}${::rdb_format_suffix}"] + + assert_aof_manifest_content $aof_manifest_file { + {file appendonly.aof.1.base.rdb seq 1 type b} + {file appendonly.aof.1.incr.aof seq 1 type i} + } + + $client set foo behavior + + set d1 [$client debug digest] + $client debug loadaof + set d2 [$client debug digest] + assert {$d1 eq $d2} + } + + clean_aof_persistence $aof_dirpath + } + + test {Multi Part AOF can create BASE (AOF format) when redis starts from empty} { + start_server_aof [list dir $server_path aof-use-rdb-preamble no] { + set client [redis [dict get $srv host] [dict get $srv port] 0 $::tls] + wait_done_loading $client + + assert_equal 1 [check_file_exist $aof_dirpath "${aof_basename}.1${::base_aof_sufix}${::aof_format_suffix}"] + + assert_aof_manifest_content $aof_manifest_file { + {file appendonly.aof.1.base.aof seq 1 type b} + {file appendonly.aof.1.incr.aof seq 1 type i} + } + + $client set foo behavior + + set d1 [$client debug digest] + $client debug loadaof + set d2 [$client debug digest] + assert {$d1 eq $d2} + } + + clean_aof_persistence $aof_dirpath } # Test Part 2 |