summaryrefslogtreecommitdiff
path: root/tests/integration/rdb.tcl
diff options
context:
space:
mode:
authorYaacovHazan <31382944+YaacovHazan@users.noreply.github.com>2021-10-04 10:32:26 +0300
committerGitHub <noreply@github.com>2021-10-04 10:32:26 +0300
commit5becb7c9c69d23aa208a8325eae0d02846590a78 (patch)
treecf4e0dce53b3459bfcc401f893171497db6b71d2 /tests/integration/rdb.tcl
parent6f4f31f167fbaf6da1939a7764606059ca7e6de1 (diff)
downloadredis-5becb7c9c69d23aa208a8325eae0d02846590a78.tar.gz
improve the stability and correctness of "Test child sending info" (#9562)
Since we measure the COW size in this test by changing some keys and reading the reported COW size, we need to ensure that the "dismiss mechanism" (#8974) will not free memory and reduce the COW size. For that, this commit changes the size of the keys to 512B (less than a page). and because some keys may fall into the same page, we are modifying ten keys on each iteration and check for at least 50% change in the COW size.
Diffstat (limited to 'tests/integration/rdb.tcl')
-rw-r--r--tests/integration/rdb.tcl21
1 files changed, 16 insertions, 5 deletions
diff --git a/tests/integration/rdb.tcl b/tests/integration/rdb.tcl
index 9b5f12328..d1d8f904e 100644
--- a/tests/integration/rdb.tcl
+++ b/tests/integration/rdb.tcl
@@ -228,7 +228,8 @@ start_server {} {
# Our COW metrics (Private_Dirty) work only on Linux
set system_name [string tolower [exec uname -s]]
-if {$system_name eq {linux}} {
+set page_size [exec getconf PAGESIZE]
+if {$system_name eq {linux} && $page_size == 4096} {
start_server {overrides {save ""}} {
test {Test child sending info} {
@@ -245,9 +246,11 @@ start_server {overrides {save ""}} {
r config set rdb-key-save-delay 200
r config set loglevel debug
- # populate the db with 10k keys of 4k each
+ # populate the db with 10k keys of 512B each (since we want to measure the COW size by
+ # changing some keys and read the reported COW size, we are using small key size to prevent from
+ # the "dismiss mechanism" free memory and reduce the COW size)
set rd [redis_deferring_client 0]
- set size 4096
+ set size 500 ;# aim for the 512 bin (sds overhead)
set cmd_count 10000
for {set k 0} {$k < $cmd_count} {incr k} {
$rd set key$k [string repeat A $size]
@@ -270,6 +273,7 @@ start_server {overrides {save ""}} {
# 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
+ set key_idx 0
while 1 {
# take samples before writing new data to the server
set cow_size [s current_cow_size]
@@ -283,12 +287,19 @@ start_server {overrides {save ""}} {
}
# trigger copy-on-write
- r setrange key$iteration 0 [string repeat B $size]
+ set modified_keys 16
+ for {set k 0} {$k < $modified_keys} {incr k} {
+ r setrange key$key_idx 0 [string repeat B $size]
+ incr key_idx 1
+ }
+ # changing 16 keys (512B each) will create at least 8192 COW (2 pages), but we don't want the test
+ # to be too strict, so we check for a change of at least 4096 bytes
+ set exp_cow [expr $cow_size + 4096]
# 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 &&
+ [s current_cow_size] >= $exp_cow &&
[s current_save_keys_processed] > $keys_processed &&
[s current_fork_perc] > 0
} else {