"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/cluster/tests/14-consistency-check.tcl" between
redis-6.0.7.tar.gz and redis-6.0.8.tar.gz

About: redis is an advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.

14-consistency-check.tcl  (redis-6.0.7):14-consistency-check.tcl  (redis-6.0.8)
skipping to change at line 42 skipping to change at line 42
proc cluster_write_keys_with_expire {id ttl} { proc cluster_write_keys_with_expire {id ttl} {
set prefix [randstring 20 20 alpha] set prefix [randstring 20 20 alpha]
set port [get_instance_attrib redis $id port] set port [get_instance_attrib redis $id port]
set cluster [redis_cluster$port] set cluster [redis_cluster$port]
for {set j 100} {$j < 200} {incr j} { for {set j 100} {$j < 200} {incr j} {
$cluster setex key_expire.$j $ttl $prefix.$j $cluster setex key_expire.$j $ttl $prefix.$j
} }
$cluster close $cluster close
} }
# make sure that replica who restarts from persistence will load keys
# that have already expired, critical for correct execution of commands
# that arrive from the master
proc test_slave_load_expired_keys {aof} { proc test_slave_load_expired_keys {aof} {
test "Slave expired keys is loaded when restarted: appendonly=$aof" { test "Slave expired keys is loaded when restarted: appendonly=$aof" {
set master_id [find_non_empty_master] set master_id [find_non_empty_master]
set replica_id [get_one_of_my_replica $master_id] set replica_id [get_one_of_my_replica $master_id]
set master_dbsize [R $master_id dbsize] set master_dbsize_0 [R $master_id dbsize]
set slave_dbsize [R $replica_id dbsize] set replica_dbsize_0 [R $replica_id dbsize]
assert_equal $master_dbsize $slave_dbsize assert_equal $master_dbsize_0 $replica_dbsize_0
# config the replica persistency and rewrite the config file to survive
# note that this needs to be done before populating the volatile keys si
# that triggers and AOFRW, and we rather the AOF file to have SETEX comm
# rather than an RDB with volatile keys
R $replica_id config set appendonly $aof
R $replica_id config rewrite
set data_ttl 5 # fill with 100 keys with 3 second TTL
set data_ttl 3
cluster_write_keys_with_expire $master_id $data_ttl cluster_write_keys_with_expire $master_id $data_ttl
after 100
# wait for replica to be in sync with master
wait_for_condition 500 10 {
[R $replica_id dbsize] eq [R $master_id dbsize]
} else {
fail "replica didn't sync"
set replica_dbsize_1 [R $replica_id dbsize] set replica_dbsize_1 [R $replica_id dbsize]
assert {$replica_dbsize_1 > $slave_dbsize} assert {$replica_dbsize_1 > $replica_dbsize_0}
R $replica_id config set appendonly $aof # make replica create persistence file
R $replica_id config rewrite if {$aof == "yes"} {
# we need to wait for the initial AOFRW to be done, otherwise
# kill_instance (which now uses SIGTERM will fail ("Writing initial
AOF, can't exit")
wait_for_condition 100 10 {
[RI $replica_id aof_rewrite_in_progress] eq 0
} else {
fail "keys didn't expire"
} else {
R $replica_id save
set start_time [clock seconds] # kill the replica (would stay down until re-started)
set end_time [expr $start_time+$data_ttl+2]
R $replica_id save
set replica_dbsize_2 [R $replica_id dbsize]
assert {$replica_dbsize_2 > $slave_dbsize}
kill_instance redis $replica_id kill_instance redis $replica_id
set master_port [get_instance_attrib redis $master_id port] # Make sure the master doesn't do active expire (sending DELs to the rep
exec ../../../src/redis-cli \ lica)
-h -p $master_port \ R $master_id DEBUG SET-ACTIVE-EXPIRE 0
{*}[rediscli_tls_config "../../../tests"] \
debug sleep [expr $data_ttl+3] > /dev/null &
while {[clock seconds] <= $end_time} { # wait for all the keys to get logically expired
#wait for $data_ttl seconds after [expr $data_ttl*1000]
# start the replica again (loading an RDB or AOF file)
restart_instance redis $replica_id restart_instance redis $replica_id
wait_for_condition 200 50 { # make sure the keys are still there
[R $replica_id ping] eq {PONG} set replica_dbsize_3 [R $replica_id dbsize]
assert {$replica_dbsize_3 > $replica_dbsize_0}
# restore settings
# wait for the master to expire all keys and replica to get the DELs
wait_for_condition 500 10 {
[R $replica_id dbsize] eq $master_dbsize_0
} else { } else {
fail "replica #$replica_id not started" fail "keys didn't expire"
} }
set replica_dbsize_3 [R $replica_id dbsize]
assert {$replica_dbsize_3 > $slave_dbsize}
} }
} }
test_slave_load_expired_keys no test_slave_load_expired_keys no
after 5000
test_slave_load_expired_keys yes test_slave_load_expired_keys yes
 End of changes. 13 change blocks. 
28 lines changed or deleted 59 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)