File: rpl_async_conn_failover.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (359 lines) | stat: -rw-r--r-- 13,875 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
# ==== Purpose ====
#
# WL#12649: Automatic reconnection for Async replication between InnoDB Clusters
#
# It tests that asynchronous replication connection is re-established to new
# sender in case the current asynchronous replication connection fails.
#
# ==== Implementation ====
# 1. Create a chain replication between server 1, 2, 3 and 4.
# 2. Insert data on server1 and verify that its synced to the end of
#    chain i.e. server4
# 3. Verify Asynchronous Replication Connection Failover is initially
#    disabled. Also verify Asynchronous Replication is initially
#    connected to server 3.
# 4. Enable Asynchronous Replication Connection Failover and set retry
#    count and retry time to 2 and verify its enabled in
#    performance_schema.replication_connection_configuration.
# 5. Stop server 3.
# 6. Verify that asynchronous replication fails with error
#    ER_RPL_ASYNC_RECONNECT_FAIL_NO_SOURCE as there is no source added to
#    table performance_schema.replication_asynchronous_connection_failover to
#    connect.
# 7. Verify that asynchronous replication tries connecting to server 3
#    two (retry_count=2) times before it fails.
# 8. Add three asynchronous connection failover servers and
#    verify that they are inserted successfully in
#    performance_schema.replication_asynchronous_connection_failover.
# 9. Restart replica IO so asynchronous replication connection failover
#    can execute and connect to new sender/source.
# 10. Verify that asynchronous replication channel gets connected to
#     server 2 and also verify that asynchronous replication tries
#     connecting to server 3 two (retry_count=2) times.
# 11. Insert more data on server1 and verify that its synced to the end
#     of chain i.e. server 4.
# 12. Stop server 2.
# 13. Verify that asynchronous replication channel gets connected to
#     server 1 and also verify that asynchronous replication tries
#     connecting to server 2 two (retry_count=2) times.
# 14. Insert more data on server1 and verify that its synced to the
#     server 4.
# 15. Stop server 1.
# 16. Even after all source are stopped the replica IO thread keeps
#     on re-trying to connect with all logged source in
#     performance_schema.replication_asynchronous_connection_failover
#     table. It tries connecting to server 3, 2 and again server 3.
# 17. Stop replica IO
# 18. Clean up
#
--source include/big_test.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc

--echo #
--echo # 1. Create a chain replication between server 1, 2, 3 and 4.
--echo #.
--let $rpl_server_count= 4
--let $rpl_topology= 1->2->3->4
--source include/rpl_init.inc


--echo #
--echo # 2. Insert data on server1 and verify that its synced to the end of
--echo #    chain i.e. server4
--echo #
--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
CREATE TABLE t1 (a INT) ENGINE = InnoDB;
INSERT INTO t1 VALUES (1);

--source include/rpl_sync.inc

--let $rpl_connection_name= server_4
--source include/rpl_connection.inc

SET @old_debug= @@GLOBAL.DEBUG;
SET GLOBAL debug = '+d,async_conn_failover_disable_weight_check';

--let $assert_text= 'There is one row on replica'
--let $assert_cond= [SELECT  COUNT(*) count FROM t1, count, 1] = 1
--source include/assert.inc


--echo #
--echo # 3. Verify Asynchronous Replication Connection Failover is initially
--echo #    disabled. Also verify Asynchronous Replication is initially
--echo #    connected to server 3.
--echo #
--let $assert_text= 'Asynchronous Replication Connection Failover is disabled'
--let $assert_cond= [SELECT SOURCE_CONNECTION_AUTO_FAILOVER FROM performance_schema.replication_connection_configuration, SOURCE_CONNECTION_AUTO_FAILOVER, 1] = 0
--source include/assert.inc

--let $wait_condition= SELECT COUNT(*) = 1 FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME='' AND PORT=$SERVER_MYPORT_3
--source include/wait_condition.inc


--echo #
--echo # 4. Enable Asynchronous Replication Connection Failover and set retry
--echo #    count and retry time to 2 and verify its enabled in
--echo #    performance_schema.replication_connection_configuration.
--echo #
--source include/stop_slave.inc
CHANGE REPLICATION SOURCE TO SOURCE_CONNECT_RETRY=1, SOURCE_RETRY_COUNT=2, SOURCE_CONNECTION_AUTO_FAILOVER=1;
--source include/start_slave.inc

# Verify Asynchronous Replication Connection Failover is enabled.
--let $assert_text= 'Asynchronous Replication Connection Failover is enabled'
--let $assert_cond= [SELECT SOURCE_CONNECTION_AUTO_FAILOVER FROM performance_schema.replication_connection_configuration, SOURCE_CONNECTION_AUTO_FAILOVER, 1] = 1
--source include/assert.inc


--echo #
--echo # 5. Stop server 3.
--echo #
--let $rpl_server_number= 3
--source include/rpl_stop_server.inc


--echo #
--echo # 6. Verify that asynchronous replication fails with error
--echo #    ER_RPL_ASYNC_RECONNECT_FAIL_NO_SOURCE as there is no source
--echo #    added to table
--echo #    performance_schema.replication_asynchronous_connection_failover to
--echo #    connect.
--echo #
--let $rpl_connection_name= server_4
--source include/rpl_connection.inc

--let $slave_io_errno=2003
--source include/wait_for_slave_io_error.inc


--echo #
--echo # 7. Verify that asynchronous replication tries connecting to server 3
--echo #    two (retry_count=2) times before it fails.
--echo #

--let $assert_text= Assert that the IO thread tried two times connecting to server_3
--let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.4.err
--let $assert_select= .*Error reconnecting to source 'root@127.0.0.1:$SERVER_MYPORT_3'. This was attempt .*, with a delay of 1 seconds between attempts.*
--let $assert_only_after= CURRENT_TEST: rpl_gtid.rpl_async_conn_failover
--let $assert_count= 2
--source include/assert_grep.inc


--echo #
--echo # 8. Add three asynchronous connection failover servers and
--echo #    verify that they are inserted successfully in
--echo #    performance_schema.replication_asynchronous_connection_failover.
--echo #

--replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3
--eval SELECT asynchronous_connection_failover_add_source('', '127.0.0.1', $SERVER_MYPORT_3, '', 60);
--replace_result $SERVER_MYPORT_2 SERVER_MYPORT_2
--eval SELECT asynchronous_connection_failover_add_source('', '127.0.0.1', $SERVER_MYPORT_2, '', 50);
--replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1
--eval SELECT asynchronous_connection_failover_add_source('', '127.0.0.1', $SERVER_MYPORT_1, '', 40);

--let $assert_text= 'There are three rows in performance_schema.replication_asynchronous_connection_failover'
--let $assert_cond= [SELECT  COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 3
--source include/assert.inc


--echo #
--echo # 9. Restart replica IO so asynchronous replication connection failover
--echo #    can execute and connect to new sender/source.
--echo #
--source include/start_slave_io.inc


--echo #
--echo # 10. Verify that asynchronous replication channel gets connected to
--echo #     server 2 and also verify that asynchronous replication tries
--echo #     connecting to server 3 two (retry_count=2) times.
--echo #
--let $wait_condition= SELECT COUNT(*) = 1 FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME='' AND PORT=$SERVER_MYPORT_2
--source include/wait_condition.inc

# Verify that it tried connecting to server_3 two (retry_count=2) times.
--let $assert_text= Assert that the IO thread tried two times connecting to server_3
--let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.4.err
--let $assert_select= .*Error connecting to source 'root@127.0.0.1:$SERVER_MYPORT_3'. This was attempt .*, with a delay of 1 seconds between attempts.*
--let $assert_only_after= CURRENT_TEST: rpl_gtid.rpl_async_conn_failover
--let $assert_count= 4
--source include/assert_grep.inc


--echo #
--echo # 11. Insert more data on server1 and verify that its synced to the end
--echo #     of chain i.e. server 4.
--echo #
--let $rpl_connection_name= server_1
--source include/rpl_connection.inc

INSERT INTO t1 VALUES (2);


# Check data is synced to server 4
--let $rpl_connection_name= server_4
--source include/rpl_connection.inc

--let $wait_condition= SELECT COUNT(*) = 2 FROM t1
--source include/wait_condition.inc


--echo #
--echo # 12. Stop server 2.
--echo #
--let $rpl_server_number= 2
--source include/rpl_stop_server.inc


--echo #
--echo # 13. Verify that asynchronous replication channel gets connected to
--echo #     server 1 and also verify that asynchronous replication tries
--echo #     connecting to server 2 two (retry_count=2) times.
--echo #

--let $rpl_connection_name= server_4
--source include/rpl_connection.inc

--let $wait_condition= SELECT COUNT(*) = 1 FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME='' AND PORT=$SERVER_MYPORT_1
--source include/wait_condition.inc

# Verify that it tried connecting to server_2 two (retry_count=2) times.
--let $assert_text= Assert that the IO thread tried two times connecting to server_2
--let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.4.err
--let $assert_select= .*Error reconnecting to source 'root@127.0.0.1:$SERVER_MYPORT_2'. This was attempt .*, with a delay of 1 seconds between attempts.*
--let $assert_only_after= CURRENT_TEST: rpl_gtid.rpl_async_conn_failover
--let $assert_count= 2
--source include/assert_grep.inc


--echo #
--echo # 14. Insert more data on server1 and verify that its synced to the
--echo #     server 4.
--echo #

--let $rpl_connection_name= server_1
--source include/rpl_connection.inc

INSERT INTO t1 VALUES (3);


# Check data is synced to server 4
--let $rpl_connection_name= server_4
--source include/rpl_connection.inc

--let $wait_condition= SELECT COUNT(*) = 3 FROM t1
--source include/wait_condition.inc


--echo #
--echo # 15. Stop server 1.
--echo #
--let $rpl_connection_name= server_4
--source include/rpl_connection.inc

--let $wait_condition= SELECT COUNT(*) = 1 FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME='' AND PORT=$SERVER_MYPORT_1
--source include/wait_condition.inc

SET GLOBAL debug = '+d,replica_retry_count_exceed';

--let $rpl_server_number= 1
--source include/rpl_stop_server.inc


--echo #
--echo # 16. Even after all source are stopped the replica IO thread keeps
--echo #     on re-trying to connect with all logged source in
--echo #     performance_schema.replication_asynchronous_connection_failover
--echo #     table. It tries connecting to server 3, 2, 1, and again 3, 2 1.
--echo #
--let $rpl_connection_name= server_4
--source include/rpl_connection.inc

SET DEBUG_SYNC= 'now WAIT_FOR wait_for_retry_count_exceed';
--let $wait_condition= SELECT COUNT(*) = 1 FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME='' AND PORT=$SERVER_MYPORT_3
--source include/wait_condition.inc
SET DEBUG_SYNC= 'now SIGNAL continue_retry_count_exceed';

SET DEBUG_SYNC= 'now WAIT_FOR wait_for_retry_count_exceed';
--let $wait_condition= SELECT COUNT(*) = 1 FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME='' AND PORT=$SERVER_MYPORT_2
--source include/wait_condition.inc
SET DEBUG_SYNC= 'now SIGNAL continue_retry_count_exceed';

SET DEBUG_SYNC= 'now WAIT_FOR wait_for_retry_count_exceed';
--let $wait_condition= SELECT COUNT(*) = 1 FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME='' AND PORT=$SERVER_MYPORT_1
--source include/wait_condition.inc
SET DEBUG_SYNC= 'now SIGNAL continue_retry_count_exceed';

SET DEBUG_SYNC= 'now WAIT_FOR wait_for_retry_count_exceed';
--let $wait_condition= SELECT COUNT(*) = 1 FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME='' AND PORT=$SERVER_MYPORT_3
--source include/wait_condition.inc
SET DEBUG_SYNC= 'now SIGNAL continue_retry_count_exceed';

SET DEBUG_SYNC= 'now WAIT_FOR wait_for_retry_count_exceed';
--let $wait_condition= SELECT COUNT(*) = 1 FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME='' AND PORT=$SERVER_MYPORT_2
--source include/wait_condition.inc
SET DEBUG_SYNC= 'now SIGNAL continue_retry_count_exceed';

SET DEBUG_SYNC= 'now WAIT_FOR wait_for_retry_count_exceed';
--let $wait_condition= SELECT COUNT(*) = 1 FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME='' AND PORT=$SERVER_MYPORT_1
--source include/wait_condition.inc
SET @@GLOBAL.DEBUG= @old_debug;
SET DEBUG_SYNC= 'now SIGNAL continue_retry_count_exceed';
SET DEBUG_SYNC= 'RESET';


--echo #
--echo # 17. Stop replica IO
--echo #
--source include/stop_slave.inc


--echo #
--echo # 18. Clean up
--echo #

CHANGE REPLICATION SOURCE TO SOURCE_CONNECTION_AUTO_FAILOVER=0;

--replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3
--eval SELECT asynchronous_connection_failover_delete_source('', '127.0.0.1', $SERVER_MYPORT_3, '');
--replace_result $SERVER_MYPORT_2 SERVER_MYPORT_2
--eval SELECT asynchronous_connection_failover_delete_source('', '127.0.0.1', $SERVER_MYPORT_2, '');
--replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1
--eval SELECT asynchronous_connection_failover_delete_source('', '127.0.0.1', $SERVER_MYPORT_1, '');

--let $rpl_server_number=1
--source include/rpl_start_server.inc

--let $_rpl_server= 2
while ($_rpl_server < $rpl_server_count)
{
  --let $rpl_connection_name= server_$_rpl_server
  --source include/rpl_connection.inc

  --let $rpl_server_number= $_rpl_server
  --source include/rpl_start_server.inc

  --disable_warnings
  --source include/start_slave.inc
  --enable_warnings

  --inc $_rpl_server
}

--let $rpl_connection_name= server_4
--source include/rpl_connection.inc
--source include/start_slave.inc

--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
DROP TABLE t1;

--source include/rpl_sync.inc

--let $rpl_skip_sync= 1
--let $rpl_only_running_threads= 1
--source include/rpl_end.inc