summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2020-05-17 18:24:48 +0200
committerantirez <antirez@gmail.com>2020-05-17 18:24:48 +0200
commit0ca2f4f824e5ae30765f6d41af67275825286cd6 (patch)
tree868c28a3dfea1f0d217633468c28a6adc4f77acf
parent96bb0c9471ddc353ffb4f53e5efbd04d26b9d91f (diff)
parent08d00dad5297440ea0680faf236a03d7390e9e51 (diff)
downloadredis-0ca2f4f824e5ae30765f6d41af67275825286cd6.tar.gz
Merge branch 'unstable' of github.com:/antirez/redis into unstable
-rw-r--r--tests/integration/replication.tcl52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/integration/replication.tcl b/tests/integration/replication.tcl
index 22b0bfeaf..e5079d9dd 100644
--- a/tests/integration/replication.tcl
+++ b/tests/integration/replication.tcl
@@ -637,3 +637,55 @@ start_server {tags {"repl"}} {
}
}
}
+
+test {replicaof right after disconnection} {
+ # this is a rare race condition that was reproduced sporadically by the psync2 unit.
+ # see details in #7205
+ start_server {tags {"repl"}} {
+ set replica1 [srv 0 client]
+ set replica1_host [srv 0 host]
+ set replica1_port [srv 0 port]
+ set replica1_log [srv 0 stdout]
+ start_server {} {
+ set replica2 [srv 0 client]
+ set replica2_host [srv 0 host]
+ set replica2_port [srv 0 port]
+ set replica2_log [srv 0 stdout]
+ start_server {} {
+ set master [srv 0 client]
+ set master_host [srv 0 host]
+ set master_port [srv 0 port]
+ $replica1 replicaof $master_host $master_port
+ $replica2 replicaof $master_host $master_port
+
+ wait_for_condition 50 100 {
+ [string match {*master_link_status:up*} [$replica1 info replication]] &&
+ [string match {*master_link_status:up*} [$replica2 info replication]]
+ } else {
+ fail "Can't turn the instance into a replica"
+ }
+
+ set rd [redis_deferring_client -1]
+ $rd debug sleep 1
+ after 100
+
+ # when replica2 will wake up from the sleep it will find both disconnection
+ # from it's master and also a replicaof command at the same event loop
+ $master client kill type replica
+ $replica2 replicaof $replica1_host $replica1_port
+ $rd read
+
+ wait_for_condition 50 100 {
+ [string match {*master_link_status:up*} [$replica2 info replication]]
+ } else {
+ fail "role change failed."
+ }
+
+ # make sure psync succeeded, and there were no unexpected full syncs.
+ assert_equal [status $master sync_full] 2
+ assert_equal [status $replica1 sync_full] 0
+ assert_equal [status $replica2 sync_full] 0
+ }
+ }
+ }
+}