Debian Codegraph @

mysql-test/suite/rpl_gtid/t/rpl_async_conn_failover_interim_add_sender.test

raw
1 # ==== Purpose ====
2 #
3 # WL#12649: Automatic reconnection for Async replication between InnoDB Clusters
4 #
5 # It verifies following Asynchronous Replication Connection Failover properties:
6 # i. Asynchronous Replication Connection Failover do not try to reconnect to
7 # the last failing sender.
8 # ii. Asynchronous Replication Connection Failover do not consider any sender
9 # new added after it has read sender list from
10 # performance_schema.replication_asynchronous_connection_failover and
11 # started selecting.
12 #
13 # ==== Implementation ====
14 #
15 # 1. Insert data on server1 and verify that its synced to the server 2.
16 # 2. Verify Asynchronous Replication Connection Failover is initially
17 # disabled. Also verify Asynchronous Replication is initially
18 # connected to server 3.
19 # 3. Enable Asynchronous Replication Connection Failover and set retry
20 # count and retry time to 2 and verify its enabled in
21 # performance_schema.replication_connection_configuration.
22 # 4. Add three asynchronous connection failover servers including
23 # server 1 to which it is currently connected. Verify that they are
24 # inserted successfully in
25 # performance_schema.replication_asynchronous_connection_failover.
26 # 5. Initialize async_conn_failover_wait_new_sender dbug sync point
27 # and stop server 2. The initialized dbug sync point will block replica
28 # IO thread after getting sender list from
29 # performance_schema.replication_asynchronous_connection_failover. Add one
30 # more sender configuration detail and verify total four sender details
31 # are inserted.
32 # 6. Now unblock async_conn_failover_wait_new_sender dbug sync point.
33 # After unblocking the dbug sync point verifies that only two senders
34 # are returned, the server 2 which failed and server 5 which was
35 # inserted after asynchronous connection failover process started were
36 # skipped.
37 # 7. Verify that asynchronous replication channel gets connected to
38 # server 3 and also verify that asynchronous replication tries
39 # connecting to server 1 two (retry_count=2) times.
40 # 8. Clean up
41 #
42 --source include/big_test.inc
43 --source include/have_debug.inc
44 --source include/have_debug_sync.inc
45
46 --let $rpl_server_count=3
47 --let $use_gtids= 1
48 --source include/master-slave.inc
49
50 --echo #
51 --echo # 1. Insert data on server1 and verify that its synced to the server 2.
52 --echo #
53 --let $rpl_connection_name= server_1
54 --source include/rpl_connection.inc
55 CREATE TABLE t1 (a INT) ENGINE = InnoDB;
56 INSERT INTO t1 VALUES (1);
57
58 --source include/rpl_sync.inc
59
60
61 --let $rpl_connection_name= server_2
62 --source include/rpl_connection.inc
63
64 --let $assert_text= 'There is one row on replica'
65 --let $assert_cond= [SELECT COUNT(*) count FROM t1, count, 1] = 1
66 --source include/assert.inc
67
68
69 --echo #
70 --echo # 2. Verify Asynchronous Replication Connection Failover is initially
71 --echo # disabled. Also verify Asynchronous Replication is initially
72 --echo # connected to server 3.
73 --echo #
74 --let $assert_text= 'Asynchronous Replication Connection Failover is disabled'
75 --let $assert_cond= [SELECT SOURCE_CONNECTION_AUTO_FAILOVER FROM performance_schema.replication_connection_configuration, SOURCE_CONNECTION_AUTO_FAILOVER, 1] = 0
76 --source include/assert.inc
77
78 --let $wait_condition= SELECT COUNT(*) = 1 FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME='' AND PORT=$MASTER_MYPORT
79 --source include/wait_condition.inc
80
81
82 --echo #
83 --echo # 3. Enable Asynchronous Replication Connection Failover and set retry
84 --echo # count and retry time to 2 and verify its enabled in
85 --echo # performance_schema.replication_connection_configuration.
86 --echo #
87 --source include/stop_slave.inc
88 CHANGE REPLICATION SOURCE TO SOURCE_CONNECT_RETRY=1, SOURCE_RETRY_COUNT=2, SOURCE_CONNECTION_AUTO_FAILOVER=1;
89 --source include/start_slave.inc
90
91 # Verify Asynchronous Replication Connection Failover is enabled.
92 --let $assert_text= 'Asynchronous Replication Connection Failover is enabled'
93 --let $assert_cond= [SELECT SOURCE_CONNECTION_AUTO_FAILOVER FROM performance_schema.replication_connection_configuration, SOURCE_CONNECTION_AUTO_FAILOVER, 1] = 1
94 --source include/assert.inc
95
96
97 --echo #
98 --echo # 4. Add three asynchronous connection failover servers including
99 --echo # server 1 to which it is currently connected. Verify that they are
100 --echo # inserted successfully in
101 --echo # performance_schema.replication_asynchronous_connection_failover.
102 --echo #
103
104 --replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1
105 --eval SELECT asynchronous_connection_failover_add_source('', '127.0.0.1', $SERVER_MYPORT_1, '', 70);
106 --replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3
107 --eval SELECT asynchronous_connection_failover_add_source('', '127.0.0.1', $SERVER_MYPORT_3, '', 50);
108 --eval SELECT asynchronous_connection_failover_add_source('', '127.0.0.1', 40001, '', 40);
109
110 --let $assert_text= 'There are three rows in performance_schema.replication_asynchronous_connection_failover'
111 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 3
112 --source include/assert.inc
113
114
115 --echo #
116 --echo # 5. Initialize async_conn_failover_wait_new_sender dbug sync point
117 --echo # and stop server 2. The initialized dbug sync point will block replica
118 --echo # IO thread after getting sender list from
119 --echo # performance_schema.replication_asynchronous_connection_failover. Add
120 --echo # one more sender configuration detail and verify total four sender
121 --echo # details are inserted. It also verifies in
122 --echo # async_conn_failover_wait_new_sender dbug point that sender list has
123 --echo # total three rows i.e. server1, 3 and 4. After stopping server1 there
124 --echo # there were no senders to connect so it resets and would consider all
125 --echo # according to wl#12649 FR8.
126 --echo #
127 SET @old_debug= @@global.debug;
128 SET GLOBAL debug = '+d,async_conn_failover_wait_new_sender, async_conn_failover_check_interim_sender';
129
130 --let $rpl_server_number= 1
131 --source include/rpl_stop_server.inc
132
133 --let $rpl_connection_name= server_2
134 --source include/rpl_connection.inc
135 SET DEBUG_SYNC= 'now WAIT_FOR wait_for_new_sender_selection';
136
137 --let $wait_condition= SELECT COUNT(*) = 1 FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME='' AND PORT=$SERVER_MYPORT_1
138 --source include/wait_condition.inc
139
140 # add a new sender with higher weight
141 --eval SELECT asynchronous_connection_failover_add_source('', '127.0.0.1', 50001, '', 80);
142
143 --let $assert_text= 'There are four rows in performance_schema.replication_asynchronous_connection_failover'
144 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 4
145 --source include/assert.inc
146
147
148 --echo #
149 --echo # 6. Now unblock async_conn_failover_wait_new_sender dbug sync point.
150 --echo # After unblocking the dbug sync point verifies that only two senders
151 --echo # are returned, the server 2 which failed and server 5 which was
152 --echo # inserted after asynchronous connection failover process started were
153 --echo # skipped.
154 --echo #
155 SET GLOBAL debug = '-d,async_conn_failover_wait_new_sender';
156 SET DEBUG_SYNC= 'now SIGNAL continue_connect_new_sender';
157
158
159 --echo #
160 --echo # 7. Verify that asynchronous replication channel gets connected to
161 --echo # server 3 and also verify that asynchronous replication tries
162 --echo # connecting to server 1 two (retry_count=2) times.
163 --echo #
164 --let $wait_condition= SELECT COUNT(*) = 1 FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME='' AND PORT=$SERVER_MYPORT_3
165 --source include/wait_condition.inc
166
167 # Verify that it tried connecting to server_1 two (retry_count=2) times.
168 --let $assert_text= Assert that the IO thread tried two times connecting to server_1
169 --let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.2.err
170 --let $assert_select= .*Error reconnecting to source '[email protected]:$SERVER_MYPORT_1'. This was attempt .*, with a delay of 1 seconds between attempts.*
171 --let $assert_only_after= CURRENT_TEST: rpl_gtid.rpl_async_conn_failover_interim_add_sender
172 --let $assert_count= 2
173 --source include/assert_grep.inc
174
175
176 --echo #
177 --echo # 8. It verifies that out of total four senders in
178 --echo # performance_schema.replication_asynchronous_connection_failover it
179 --echo # will only consider three servers skipping the last failing sender.
180 --echo # It verifies that
181 --echo # async_conn_failover_wait_new_sender dbug point that sender list has
182 --echo # total three rows. As the sender list os not exhausted it does not
183 --echo # consider wl#12649 FR8 and remove the last failing sender from sender
184 --echo # to be considered for async failover connection.
185 --echo #
186
187 --let $rpl_server_number=1
188 --source include/rpl_start_server.inc
189
190 --let $rpl_connection_name= server_2
191 --source include/rpl_connection.inc
192
193 SET GLOBAL debug = '+d,async_conn_failover_wait_new_4sender';
194
195 --let $rpl_server_number= 3
196 --source include/rpl_stop_server.inc
197
198 --let $rpl_connection_name= server_2
199 --source include/rpl_connection.inc
200
201 --let $wait_condition= SELECT COUNT(*) = 0 FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME='' AND PORT=$SERVER_MYPORT_3
202 --source include/wait_condition.inc
203
204 SET DEBUG_SYNC= 'now WAIT_FOR wait_for_new_4sender_selection';
205 SET GLOBAL debug = '-d,async_conn_failover_wait_new_4sender';
206 SET DEBUG_SYNC= 'now SIGNAL continue_connect_new_4sender';
207
208 --let $wait_condition= SELECT COUNT(*) = 1 FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME='' AND PORT=50001
209 --source include/wait_condition.inc
210
211
212 --echo #
213 --echo # 9. Clean up
214 --echo #
215
216 --let $rpl_connection_name= server_1
217 --source include/rpl_connection.inc
218 DROP TABLE t1;
219
220 --let $rpl_connection_name= server_2
221 --source include/rpl_connection.inc
222
223 SET GLOBAL debug= @old_debug;
224
225 --let $slave_error_param= Last_IO_Errno
226 --let $slave_io_errno=2003
227 --source include/stop_slave.inc
228 --let $rpl_reset_slave_all= 1
229 --source include/rpl_reset_slave.inc
230 --let $rpl_reset_slave_all=
231
232 --replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1
233 --eval SELECT asynchronous_connection_failover_delete_source('', '127.0.0.1', $SERVER_MYPORT_1, '');
234 --replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3
235 --eval SELECT asynchronous_connection_failover_delete_source('', '127.0.0.1', $SERVER_MYPORT_3, '');
236 --eval SELECT asynchronous_connection_failover_delete_source('', '127.0.0.1', 40001, '');
237 --eval SELECT asynchronous_connection_failover_delete_source('', '127.0.0.1', 50001, '');
238
239 DROP TABLE IF EXISTS t1;
240
241 --let $rpl_server_number= 3
242 --source include/rpl_start_server.inc
243
244 --let $rpl_skip_sync= 1
245 --let $rpl_only_running_threads= 1
246 --source include/rpl_end.inc