@@ -60,3 +60,53 @@ start_server {} {
6060 }
6161 }
6262}}
63+
64+
65+ start_server {tags {" psync2" }} {
66+ start_server {} {
67+ start_server {} {
68+
69+ for {set j 0} {$j < 3} {incr j} {
70+ set R($j ) [srv [expr 0-$j ] client]
71+ set R_host($j ) [srv [expr 0-$j ] host]
72+ set R_port($j ) [srv [expr 0-$j ] port]
73+ $R($j) CONFIG SET repl-ping-replica-period 1
74+ }
75+
76+ test " Chained replicas disconnect when replica re-connect with the same master" {
77+ # Add a second replica as a chained replica of the current replica
78+ $R(1) replicaof $R_host(0) $R_port(0)
79+ $R(2) replicaof $R_host(1) $R_port(1)
80+ wait_for_condition 50 1000 {
81+ [status $R(2) master_link_status] == " up"
82+ } else {
83+ fail " Chained replica not replicating from its master"
84+ }
85+
86+ # Do a write on the master, and wait for 3 seconds for the master to
87+ # send some PINGs to its replica
88+ $R(0) INCR counter2
89+ after 2000
90+ set sync_partial_master [status $R(0) sync_partial_ok]
91+ set sync_partial_replica [status $R(1) sync_partial_ok]
92+ $R(0) CONFIG SET repl-ping-replica-period 100
93+
94+ # Disconnect the master's direct replica
95+ $R(0) client kill type replica
96+ wait_for_condition 50 1000 {
97+ [status $R(1) master_link_status] == " up" &&
98+ [status $R(2) master_link_status] == " up" &&
99+ [status $R(0) sync_partial_ok] == $sync_partial_master + 1 &&
100+ [status $R(1) sync_partial_ok] == $sync_partial_replica + 1
101+ } else {
102+ fail " Disconnected replica failed to PSYNC with master"
103+ }
104+
105+ # Verify that the replica and its replica's meaningful and real
106+ # offsets match with the master
107+ assert_equal [status $R(0) master_repl_offset] [status $R(1) master_repl_offset]
108+ assert_equal [status $R(0) master_repl_offset] [status $R(2) master_repl_offset]
109+ assert_equal [status $R(0) master_repl_meaningful_offset] [status $R(1) master_repl_meaningful_offset]
110+ assert_equal [status $R(0) master_repl_meaningful_offset] [status $R(2) master_repl_meaningful_offset]
111+ }
112+ }}}
0 commit comments