diff options
author | Oran Agra <oran@redislabs.com> | 2021-11-04 08:44:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-04 08:44:18 +0200 |
commit | d04f306931f337e70a9cb270f0bbd1a202eedeb0 (patch) | |
tree | dce358805606d677ac3551566a0732c8812a045a /tests/cluster | |
parent | f27083a4a8a6682e391a533724c904c69852c0a0 (diff) | |
download | redis-d04f306931f337e70a9cb270f0bbd1a202eedeb0.tar.gz |
Fix race condition in cluster test 22-replica-in-sync (#9721)
there was a chance that by the time the assertion is executed,
the replica already manages to reconnect.
now we make sure the replica is unable to re-connect to the master.
additionally, we wait for some gossip from the disconnected replica,
to see that it doesn't mess things up.
unrelated: fix a typo when trying to exhaust the backlog, one that
didn't have any harmful implications
Co-authored-by: Madelyn Olson <madelyneolson@gmail.com>
Diffstat (limited to 'tests/cluster')
-rw-r--r-- | tests/cluster/tests/22-replica-in-sync.tcl | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/tests/cluster/tests/22-replica-in-sync.tcl b/tests/cluster/tests/22-replica-in-sync.tcl index db1590560..b5645aa75 100644 --- a/tests/cluster/tests/22-replica-in-sync.tcl +++ b/tests/cluster/tests/22-replica-in-sync.tcl @@ -25,6 +25,16 @@ proc is_replica_online {info_repl} { return $result } +proc get_last_pong_time {node_id target_cid} { + foreach item [split [R $node_id cluster nodes] \n] { + set args [split $item " "] + if {[lindex $args 0] eq $target_cid} { + return [lindex $args 5] + } + } + fail "Target node ID was not present" +} + set master_id 0 test "Fill up primary with data" { @@ -74,7 +84,7 @@ test "Replica in loading state is hidden" { for {set j 0} {$j < $num} {incr j} { set key "{0}" append key $j - R $master_id set key $value + R $master_id set $key $value } R $master_id exec @@ -109,10 +119,28 @@ test "Replica in loading state is hidden" { } test "Check disconnected replica not hidden from slots" { + # We want to disconnect the replica, but keep it alive so it can still gossip + + # Make sure that the replica will not be able to re-connect to the master + R $master_id config set requirepass asdf + # Disconnect replica from primary R $master_id client kill type replica + # Check master to have no replicas assert {[s $master_id connected_slaves] == 0} + + set replica_cid [R $replica_id cluster myid] + set initial_pong [get_last_pong_time $master_id $replica_cid] + wait_for_condition 50 100 { + $initial_pong != [get_last_pong_time $master_id $replica_cid] + } else { + fail "Primary never received gossip from replica" + } + # Check that replica is still in the cluster slots assert {[is_in_slots $master_id $replica]} + + # undo config + R $master_id config set requirepass "" } |