Debian Codegraph @

mysql-test/suite/rpl/include/multisource.inc

raw
1 #
2 # This include file is used by more than one test suite
3 # (currently multisource and binlog_encryption).
4 # Please check all dependent tests after modifying it
5 #
6 # Usage:
7 # --source suite/rpl/include/multisource.inc
8 #
9 # By default, the script expects the length of the 2nd binary log to be
10 # $binlog_start_pos + length(Gtid_list event) + 2 x length(Binlog_checkpoint event)
11 # Some tests can have specific configuration which would change it,
12
13 #
14 # Test basic replication functionality
15 # in multi-source setup
16 #
17
18 --source include/not_embedded.inc
19 --source include/have_innodb.inc
20 --source include/have_perfschema.inc
21 --source include/binlog_start_pos.inc
22 --let $rpl_server_count= 0
23
24 --connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3)
25
26 # MDEV-3984: crash/read of freed memory when changing master with named connection
27 # This fails after adding the new master 'abc', check we do not free twice.
28 --error ER_RELAY_LOG_INIT
29 change master 'abc' to relay_log_file='';
30 # This fails before adding the new master, check that we do free it.
31 --error ER_WRONG_ARGUMENTS
32 change master 'abc2' to master_host='';
33
34
35 # Start replication from the first master
36
37 --replace_result $SERVER_MYPORT_1 MYPORT_1
38 eval change master 'master1' to
39 master_port=$SERVER_MYPORT_1,
40 master_host='127.0.0.1',
41 master_user='root',
42 master_ssl_verify_server_cert=0;
43
44 start slave 'master1';
45 set default_master_connection = 'master1';
46 --source include/wait_for_slave_to_start.inc
47
48 --connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1)
49 --save_master_pos
50
51 --connection slave
52 --sync_with_master 0,'master1'
53
54 # Here and further: add an extra check on SQL thread status
55 # as the normal sync is not always enough
56 --source include/wait_for_sql_thread_read_all.inc
57
58 # each of the 3 commands should produce
59 # 'master1' status
60
61 let $wait_for_all= 1;
62 let $show_statement= SHOW ALL SLAVES STATUS;
63 let $field= Slave_IO_State;
64 let $condition= = 'Waiting for master to send event';
65 --source include/wait_show_condition.inc
66
67 --echo #
68 --echo # Checking SHOW SLAVE 'master1' STATUS
69 --echo #
70 --let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno
71 --let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/
72 --let $slave_name= 'master1'
73 --source include/show_slave_status.inc
74 --let $slave_name=
75
76 --echo #
77 --echo # Checking SHOW SLAVE STATUS
78 --echo #
79 --source include/show_slave_status.inc
80
81 --echo #
82 --echo # Checking SHOW ALL SLAVES STATUS
83 --echo #
84 --let $all_slaves_status= 1
85 --let $status_items= Connection_name, Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno, Slave_heartbeat_period
86 --source include/show_slave_status.inc
87 --let $all_slaves_status=
88 --echo #
89
90
91 # Check that replication actually works
92
93 --connection master1
94
95 --disable_warnings
96 drop database if exists db1;
97 --enable_warnings
98 create database db1;
99 use db1;
100 create table t1 (i int auto_increment, f1 varchar(16), primary key pk (i,f1)) engine=MyISAM;
101 insert into t1 (f1) values ('one'),('two');
102 --save_master_pos
103
104 --connection slave
105 --sync_with_master 0,'master1'
106
107 --sorted_result
108 select * from db1.t1;
109
110 --let $datadir = `SELECT @@datadir`
111
112 --echo # List of relay log files in the datadir
113 --list_files $datadir mysqld-relay-bin-master1.*
114
115 # Check that relay logs are recognizable
116
117 let binlog_start=4;
118 let binlog_file=;
119 source include/show_relaylog_events.inc;
120 let binlog_file= mysqld-relay-bin-master1.000002;
121 source include/show_relaylog_events.inc;
122
123 # Try to configure connection with the same name again,
124 # should get an error because the slave is running
125
126 --replace_result $SERVER_MYPORT_2 MYPORT_2
127 --error ER_SLAVE_MUST_STOP
128 eval change master 'master1' to
129 master_port=$SERVER_MYPORT_2,
130 master_host='127.0.0.1',
131 master_user='root';
132
133 # Try to configure using the default connection name
134 # (which is 'master1' at the moment),
135 # again, should get an error
136
137 --replace_result $SERVER_MYPORT_2 MYPORT_2
138 --error ER_SLAVE_MUST_STOP
139 eval change master to
140 master_port=$SERVER_MYPORT_2,
141 master_host='127.0.0.1',
142 master_user='root';
143
144 # Try to configure a connection with the same master
145 # using a different name, should get a conflict
146
147 --replace_result $SERVER_MYPORT_1 MYPORT_1
148 --error ER_CONNECTION_ALREADY_EXISTS
149 eval change master 'master2' to
150 master_port=$SERVER_MYPORT_1,
151 master_host='127.0.0.1',
152 master_user='root';
153
154
155 # Set up a proper 'default' connection to master2
156
157 set default_master_connection = '';
158
159 --replace_result $SERVER_MYPORT_2 MYPORT_2
160 eval change master to
161 master_port=$SERVER_MYPORT_2,
162 master_host='127.0.0.1',
163 master_user='root',
164 master_ssl_verify_server_cert=0,
165 master_use_gtid=no;
166
167 start slave;
168 --source include/wait_for_slave_to_start.inc
169
170 --source include/wait_for_sql_thread_read_all.inc
171
172 # See both connections in the same status output
173
174 let $wait_for_all= 1;
175 let $show_statement= SHOW ALL SLAVES STATUS;
176 let $field= Slave_IO_State;
177 let $condition= = 'Waiting for master to send event';
178 --source include/wait_show_condition.inc
179
180 --echo #
181 --echo # Checking SHOW ALL SLAVES STATUS
182 --echo #
183 --let $all_slaves_status= 1
184 --let $status_items= Connection_name, Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno, Slave_heartbeat_period
185 --let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/ /$SERVER_MYPORT_2/MYPORT_2/
186 --source include/show_slave_status.inc
187 --let $all_slaves_status=
188 --echo #
189
190 # Check that replication from two servers actually works
191
192 --connection master1
193
194 insert into t1 (f1) values ('three');
195 --save_master_pos
196
197 --connect (master2,127.0.0.1,root,,,$SERVER_MYPORT_2)
198
199 --disable_warnings
200 drop database if exists db2;
201 --enable_warnings
202 create database db2;
203 use db2;
204 create table t1 (pk int auto_increment primary key, f1 int) engine=InnoDB;
205 begin;
206 insert into t1 (f1) values (1),(2);
207
208 --connection slave
209 --sync_with_master 0,'master1'
210
211 --connection master2
212 --save_master_pos
213
214 --connection slave
215 --sync_with_master 0
216 --sorted_result
217 select * from db1.t1;
218 select * from db2.t1;
219
220 --connection master2
221 commit;
222 --save_master_pos
223
224 --connection slave
225 --sync_with_master 0
226 --sorted_result
227 select * from db2.t1;
228
229 # Flush and purge logs on one master,
230 # make sure slaves don't get confused
231
232 --connection master1
233 flush logs;
234 --source include/wait_for_binlog_checkpoint.inc
235 --save_master_pos
236 --connection slave
237 --sync_with_master 0, 'master1'
238
239 --connection master1
240 purge binary logs to 'master-bin.000002';
241 # Additional events: 43 (Gtid_list) + 2 x 44 (Binlog_checkpoint) = 131
242 let filesize=`select $binlog_start_pos+131`;
243 --replace_result $filesize filesize
244 show binary logs;
245 insert into t1 (f1) values ('four');
246 create table db1.t3 (f1 int) engine=InnoDB;
247 --save_master_pos
248
249 --connection slave
250 --sync_with_master 0,'master1'
251
252 --source include/wait_for_sql_thread_read_all.inc
253
254 let $wait_for_all= 1;
255 let $show_statement= SHOW ALL SLAVES STATUS;
256 let $field= Slave_IO_State;
257 let $condition= = 'Waiting for master to send event';
258 --source include/wait_show_condition.inc
259
260 --echo #
261 --echo # Checking SHOW ALL SLAVES STATUS
262 --echo #
263 --let $all_slaves_status= 1
264 --let $status_items= Connection_name, Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno, Slave_heartbeat_period
265 --let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/ /$SERVER_MYPORT_2/MYPORT_2/
266 --source include/show_slave_status.inc
267 --let $all_slaves_status=
268 --echo #
269
270 --echo #
271 --echo # MDEV:16437: merge 5.7 P_S replication instrumentation and tables
272 --echo #
273 --replace_column 2 #
274 query_vertical SELECT * FROM performance_schema.replication_applier_status_by_coordinator;
275
276 --sorted_result
277 select * from db1.t1;
278
279 # This should show relay log events for the default master
280 # (the one with the empty name)
281 let binlog_file=;
282 source include/show_relaylog_events.inc;
283 let binlog_file= mysqld-relay-bin.000002;
284 source include/show_relaylog_events.inc;
285
286 # Make sure we don't lose control over replication connections
287 # after reconnecting to the slave
288
289 --disconnect slave
290 --connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3)
291
292 stop slave io_thread;
293 show status like 'Slave_running';
294 set default_master_connection = 'master1';
295 show status like 'Slave_running';
296
297 # Cleanup
298
299 drop database db1;
300 drop database db2;
301
302 --source include/reset_master_slave.inc
303 --disconnect slave
304
305 --connection master1
306 drop database db1;
307 --source include/reset_master_slave.inc
308 --disconnect master1
309
310 --connection master2
311 drop database db2;
312 --source include/reset_master_slave.inc
313 --disconnect master2
314