diff options
author | YaacovHazan <yaacov.hazan@redislabs.com> | 2020-12-20 20:23:20 +0200 |
---|---|---|
committer | Oran Agra <oran@redislabs.com> | 2021-01-07 16:14:29 +0200 |
commit | ea930a352ca748c0fa49a1b2ee894ea92bc83b0e (patch) | |
tree | 6976a6ac38819ee041479ef0af317eeb10599719 /tests/integration/rdb.tcl | |
parent | f9dacf8aacc8af7fdcb41bc9f927b42390557f7d (diff) | |
download | redis-ea930a352ca748c0fa49a1b2ee894ea92bc83b0e.tar.gz |
Report child copy-on-write info continuously
Add INFO field, rdb_active_cow_size, to report COW of a live fork child while
it's active.
- once in 1024 keys check the time, and if there's more than one second since
the last report send a report to the parent via the pipe.
- refactor the child_info_data struct, it's an implementation detail that
shouldn't be in the server struct, and not used to communicate data between
caller and callee
- remove the magic value from that struct (not sure what it was good for), and
instead add handling of short reads.
- add another value to the structure, cow_type, to indicate if the report is
for the new rdb_active_cow_size field, or it's the last report of a
successful operation
- add new Module API to report the active COW
- add more asserts variants to test.tcl
Diffstat (limited to 'tests/integration/rdb.tcl')
-rw-r--r-- | tests/integration/rdb.tcl | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/tests/integration/rdb.tcl b/tests/integration/rdb.tcl index aadfe281f..cd4dfbadb 100644 --- a/tests/integration/rdb.tcl +++ b/tests/integration/rdb.tcl @@ -198,3 +198,78 @@ test {client freed during loading} { exec kill [srv 0 pid] } } + +start_server {overrides {save ""}} { + test {Test child sending COW info} { + # make sure that rdb_last_cow_size and current_cow_size are zero (the test using new server), + # so that the comparisons during the test will be valid + assert {[s current_cow_size] == 0} + assert {[s rdb_last_cow_size] == 0} + + # using a 200us delay, the bgsave is empirically taking about 10 seconds. + # we need it to take more than some 5 seconds, since redis only report COW once a second. + r config set rdb-key-save-delay 200 + + # populate the db with 10k keys of 4k each + set rd [redis_deferring_client 0] + set size 4096 + set cmd_count 10000 + for {set k 0} {$k < $cmd_count} {incr k} { + $rd set key$k [string repeat A $size] + } + + for {set k 0} {$k < $cmd_count} {incr k} { + catch { $rd read } + } + + $rd close + + # start background rdb save + r bgsave + + # on each iteration, we will write some key to the server to trigger copy-on-write, and + # wait to see that it reflected in INFO. + set iteration 1 + while 1 { + # take a sample before writing new data to the server + set cow_size [s current_cow_size] + if {$::verbose} { + puts "COW info before copy-on-write: $cow_size" + } + + # trigger copy-on-write + r setrange key$iteration 0 [string repeat B $size] + + # wait to see that current_cow_size value updated (as long as the child is in progress) + wait_for_condition 80 100 { + [s rdb_bgsave_in_progress] == 0 || + [s current_cow_size] >= $cow_size + $size + } else { + if {$::verbose} { + puts "COW info on fail: [s current_cow_size]" + } + fail "COW info didn't report" + } + + # for no accurate, stop after 2 iterations + if {!$::accurate && $iteration == 2} { + break + } + + # stop iterating if the bgsave completed + if { [s rdb_bgsave_in_progress] == 0 } { + break + } + + incr iteration 1 + } + + # make sure we saw report of current_cow_size + assert_morethan_equal $iteration 2 + + # if bgsave completed, check that rdb_last_cow_size value is at least as last rdb_active_cow_size. + if { [s rdb_bgsave_in_progress] == 0 } { + assert_morethan_equal [s rdb_last_cow_size] $cow_size + } + } +}
\ No newline at end of file |