Debian Codegraph @

mysql-test/suite/multi_source/multisource_for_channel.test

raw
1 #
2 # This is the basic test of support mysql syntax "for channel" used for
3 # multi-source replication
4 #
5 # Test basic replication functionality in multi-source setup
6 #
7
8 --source include/not_embedded.inc
9 --source include/have_innodb.inc
10 --source include/have_perfschema.inc
11 --source include/binlog_start_pos.inc
12 --let $rpl_server_count= 0
13
14 RESET MASTER;
15
16 --connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3)
17
18 # MDEV-3984: crash/read of freed memory when changing master with named connection
19 # This fails after adding the new master 'abc1', check we do not free twice.
20 --error ER_RELAY_LOG_INIT
21 change master to relay_log_file='' for channel 'abc1';
22 # This fails before adding the new master, check that we do free it.
23 --error ER_WRONG_ARGUMENTS
24 change master to master_host='' for channel 'abc2';
25
26 # Start replication from the first master
27
28 --replace_result $SERVER_MYPORT_1 MYPORT_1
29 eval change master to
30 master_port=$SERVER_MYPORT_1,
31 master_host='127.0.0.1',
32 master_user='root', master_ssl_verify_server_cert=0,
33 master_use_gtid=no
34 for channel 'master1';
35
36 start slave for channel 'master1';
37 set default_master_connection = 'master1';
38 --source include/wait_for_slave_to_start.inc
39
40 --connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1)
41 --save_master_pos
42
43 --connection slave
44 --sync_with_master 0,'master1'
45
46 # Here and further: add an extra check on SQL thread status
47 # as the normal sync is not always enough
48 --source include/wait_for_sql_thread_read_all.inc
49
50 # each of the 3 commands should produce
51 # 'master1' status
52
53 let $wait_for_all= 1;
54 let $show_statement= SHOW ALL SLAVES STATUS;
55 let $field= Slave_IO_State;
56 let $condition= = 'Waiting for master to send event';
57 --source include/wait_show_condition.inc
58
59 --echo #
60 --echo # Checking SHOW SLAVE 'master1' STATUS
61 --echo #
62 --let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno
63 --let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/
64 --let $slave_name= 'master1'
65 --let for_channel= 1
66 --source include/show_slave_status.inc
67 --let $slave_name=
68 --let for_channel=
69
70 --echo #
71 --echo # Checking SHOW SLAVE STATUS
72 --echo #
73 --source include/show_slave_status.inc
74
75 --echo #
76 --echo # Checking SHOW ALL SLAVES STATUS
77 --echo #
78 --let $all_slaves_status= 1
79 --let $status_items= Connection_name, Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno, Slave_heartbeat_period
80 --source include/show_slave_status.inc
81 --let $all_slaves_status=
82 --echo #
83
84
85 # Check that replication actually works
86
87 --connection master1
88
89 --disable_warnings
90 drop database if exists db1;
91 --enable_warnings
92 create database db1;
93 use db1;
94 create table t1 (i int auto_increment, f1 varchar(16), primary key pk (i,f1)) engine=MyISAM;
95 insert into t1 (f1) values ('one'),('two');
96 --save_master_pos
97
98 --connection slave
99 --sync_with_master 0,'master1'
100
101 --sorted_result
102 select * from db1.t1;
103
104 --let $datadir = `SELECT @@datadir`
105
106 --echo # List of relay log files in the datadir
107 --list_files $datadir mysqld-relay-bin-master1.*
108
109 # Check that relay logs are recognizable
110
111 let binlog_start=4;
112 let binlog_file=;
113 source include/show_relaylog_events.inc;
114 let binlog_file= mysqld-relay-bin-master1.000002;
115 source include/show_relaylog_events.inc;
116
117 # Try to configure connection with the same name again,
118 # should get an error because the slave is running
119
120 --replace_result $SERVER_MYPORT_2 MYPORT_2
121 --error ER_SLAVE_MUST_STOP
122 eval change master to
123 master_port=$SERVER_MYPORT_2,
124 master_host='127.0.0.1',
125 master_user='root'
126 for channel 'master1';
127
128 # Try to configure using the default connection name
129 # (which is 'master1' at the moment),
130 # again, should get an error
131
132 --replace_result $SERVER_MYPORT_2 MYPORT_2
133 --error ER_SLAVE_MUST_STOP
134 eval change master to
135 master_port=$SERVER_MYPORT_2,
136 master_host='127.0.0.1',
137 master_user='root';
138
139 # Try to configure a connection with the same master
140 # using a different name, should get a conflict
141
142 --replace_result $SERVER_MYPORT_1 MYPORT_1
143 --error ER_CONNECTION_ALREADY_EXISTS
144 eval change master to
145 master_port=$SERVER_MYPORT_1,
146 master_host='127.0.0.1',
147 master_user='root' for channel 'master2';
148
149
150 # Set up a proper 'default' connection to master2
151
152 set default_master_connection = '';
153
154 --replace_result $SERVER_MYPORT_2 MYPORT_2
155 eval change master to
156 master_port=$SERVER_MYPORT_2,
157 master_host='127.0.0.1',
158 master_user='root', master_ssl_verify_server_cert=0,
159 master_use_gtid=no;
160
161 start slave;
162 --source include/wait_for_slave_to_start.inc
163
164 --source include/wait_for_sql_thread_read_all.inc
165
166 # See both connections in the same status output
167
168 let $wait_for_all= 1;
169 let $show_statement= SHOW ALL SLAVES STATUS;
170 let $field= Slave_IO_State;
171 let $condition= = 'Waiting for master to send event';
172 --source include/wait_show_condition.inc
173
174 --echo #
175 --echo # Checking SHOW ALL SLAVES STATUS
176 --echo #
177 --let $all_slaves_status= 1
178 --let $status_items= Connection_name, Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno, Slave_heartbeat_period
179 --let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/ /$SERVER_MYPORT_2/MYPORT_2/
180 --source include/show_slave_status.inc
181 --let $all_slaves_status=
182 --echo #
183
184 # Check that replication from two servers actually works
185
186 --connection master1
187
188 insert into t1 (f1) values ('three');
189 --save_master_pos
190
191 --connect (master2,127.0.0.1,root,,,$SERVER_MYPORT_2)
192
193 --disable_warnings
194 drop database if exists db2;
195 --enable_warnings
196 create database db2;
197 use db2;
198 create table t1 (pk int auto_increment primary key, f1 int) engine=InnoDB;
199 begin;
200 insert into t1 (f1) values (1),(2);
201
202 --connection slave
203 --sync_with_master 0,'master1'
204
205 --connection master2
206 --save_master_pos
207
208 --connection slave
209 --sync_with_master 0
210 --sorted_result
211 select * from db1.t1;
212 select * from db2.t1;
213
214 --connection master2
215 commit;
216 --save_master_pos
217
218 --connection slave
219 --sync_with_master 0
220 --sorted_result
221 select * from db2.t1;
222
223 # Flush and purge logs on one master,
224 # make sure slaves don't get confused
225
226 --connection master1
227 flush logs;
228 --source include/wait_for_binlog_checkpoint.inc
229 --save_master_pos
230 --connection slave
231 --sync_with_master 0, 'master1'
232
233 --connection master1
234 purge binary logs to 'master-bin.000002';
235 # Additional events: 43 (Gtid_list) + 2 x 44 (Binlog_checkpoint) = 131
236 let filesize=`select $binlog_start_pos+131`;
237 --replace_result $filesize filesize
238 show binary logs;
239 insert into t1 (f1) values ('four');
240 create table db1.t3 (f1 int) engine=InnoDB;
241 --save_master_pos
242
243 --connection slave
244 --sync_with_master 0,'master1'
245
246 --source include/wait_for_sql_thread_read_all.inc
247
248 let $wait_for_all= 1;
249 let $show_statement= SHOW ALL SLAVES STATUS;
250 let $field= Slave_IO_State;
251 let $condition= = 'Waiting for master to send event';
252 --source include/wait_show_condition.inc
253
254 --echo #
255 --echo # Checking SHOW ALL SLAVES STATUS
256 --echo #
257 --let $all_slaves_status= 1
258 --let $status_items= Connection_name, Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno, Slave_heartbeat_period
259 --let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/ /$SERVER_MYPORT_2/MYPORT_2/
260 --source include/show_slave_status.inc
261 --let $all_slaves_status=
262 --echo #
263
264 --echo #
265 --echo # MDEV:16437: merge 5.7 P_S replication instrumentation and tables
266 --echo #
267 --replace_column 2 #
268 query_vertical SELECT * FROM performance_schema.replication_applier_status_by_coordinator;
269
270 --sorted_result
271 select * from db1.t1;
272
273 # This should show relay log events for the default master
274 # (the one with the empty name)
275 let binlog_file=;
276 source include/show_relaylog_events.inc;
277 let binlog_file= mysqld-relay-bin.000002;
278 source include/show_relaylog_events.inc;
279
280 # Make sure we don't lose control over replication connections
281 # after reconnecting to the slave
282
283 --disconnect slave
284 --connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3)
285
286 stop slave io_thread;
287 show status like 'Slave_running';
288 set default_master_connection = 'master1';
289 show status like 'Slave_running';
290
291 --echo
292 --echo #
293 --echo # syntax compatible test
294 --echo #
295 --echo
296 --echo #
297 --echo # show relaylog events
298 --echo #
299 --replace_regex /Server ver:.*/Server ver: Version/
300 SHOW RELAYLOG EVENTS for channel 'master1';
301
302 --echo
303 --echo show slave status for channel 'master1'
304 --let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno
305 --let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/
306 --let $slave_name= 'master1'
307 --let $for_channel= 1
308 --source include/show_slave_status.inc
309
310 --echo
311 --echo #
312 --echo # stop slave
313 --echo #
314 STOP SLAVE for channel 'master1';
315
316 --echo
317 --echo show slave status for channel 'master1'
318 --let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno
319 --let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/
320 --let $slave_name= 'master1'
321 --let $for_channel= 1
322 --source include/show_slave_status.inc
323
324 --echo
325 --echo #
326 --echo # start slave
327 --echo #
328 START SLAVE for channel 'master1';
329 --source include/wait_for_slave_to_start.inc
330
331 # Force some data into the relay log to ensure that we get a new relay log
332 --connection master1
333 create table foo (a int);
334 drop table foo;
335 --save_master_pos
336 --connection slave
337 --sync_with_master 0,'master1'
338 --source include/wait_for_sql_thread_read_all.inc
339
340 --echo
341 --echo show slave status for channel 'master1'
342 --let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno
343 --let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/ /Preparing/Yes/
344 --let $slave_name= 'master1'
345 --let $for_channel= 1
346 --source include/show_slave_status.inc
347
348 --echo
349 --echo #
350 --echo # flush relay logs
351 --echo #
352 FLUSH RELAY LOGS for channel 'master1';
353 --source include/wait_for_sql_thread_read_all.inc
354
355 --echo
356 --echo show slave status for channel 'master1'
357 --let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno
358 --let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/
359 --let $slave_name= 'master1'
360 --let $for_channel= 1
361 --source include/show_slave_status.inc
362
363 --echo
364 --echo #
365 --echo # stop slave
366 --echo #
367 STOP SLAVE for channel 'master1';
368
369 --echo
370 --echo show slave status for channel 'master1'
371 --let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno
372 --let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/
373 --let $slave_name= 'master1'
374 --let $for_channel= 1
375 --source include/show_slave_status.inc
376
377 --echo
378 --echo #
379 --echo # reset slave
380 --echo #
381 RESET SLAVE for channel 'master1';
382
383 --echo
384 --echo show slave status for channel 'master1'
385 --let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno
386 --let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/
387 --let $slave_name= 'master1'
388 --let $for_channel= 1
389 --source include/show_slave_status.inc
390
391 --echo
392 --echo #
393 --echo # show relaylog events after reset slave
394 --echo #
395 SHOW RELAYLOG EVENTS for channel 'master1';
396
397 --let $slave_name=
398 --let for_channel=
399
400 --echo
401 --echo #
402 --echo # check error syntax
403 --echo #
404 --error ER_WRONG_ARGUMENTS
405 RESET SLAVE 'master1' for channel 'mmaster2';
406 --error ER_WRONG_ARGUMENTS
407 STOP SLAVE 'master1' for channel 'master2';
408 --error ER_WRONG_ARGUMENTS
409 FLUSH RELAY LOGS 'master1' for channel 'master2';
410 --error ER_WRONG_ARGUMENTS
411 START SLAVE 'master1' for channel 'master2';
412 --error ER_WRONG_ARGUMENTS
413 SHOW RELAYLOG 'master1' EVENTS for channel 'master2';
414 --error ER_WRONG_ARGUMENTS
415 SHOW SLAVE 'master1' STATUS for channel 'master2';
416
417 --echo
418 # Cleanup
419 drop database db1;
420 drop database db2;
421
422 --source include/reset_master_slave.inc
423 --disconnect slave
424
425 --connection master1
426 drop database db1;
427 --source include/reset_master_slave.inc
428 --disconnect master1
429
430 --connection master2
431 drop database db2;
432 --source include/reset_master_slave.inc
433 --disconnect master2
434
435 #
436 # Check channel as a keyword
437 #
438 --connection default
439 CREATE TABLE channel (channel int);
440 DROP TABLE channel;