Debian Codegraph @

mysql-test/suite/rpl/t/rpl_parallel_multilevel.test

raw
1 --source include/have_innodb.inc
2 --source include/have_debug_sync.inc
3 --let $rpl_topology=1->2->3->4
4 --source include/rpl_init.inc
5
6 # Test parallel replication with a multi-level replication hierarchy.
7
8 --connection server_1
9 ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
10 CREATE TABLE t1 (a int PRIMARY KEY, b INT) ENGINE=InnoDB;
11 --save_master_pos
12
13 --connection server_2
14 --sync_with_master
15 --save_master_pos
16 SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
17 --source include/stop_slave.inc
18 SET GLOBAL slave_parallel_threads=10;
19 CHANGE MASTER TO master_use_gtid=slave_pos;
20 SET @old_parallel_mode=@@GLOBAL.slave_parallel_mode;
21 SET GLOBAL slave_parallel_mode='optimistic';
22
23
24 --connection server_3
25 --sync_with_master
26 --save_master_pos
27 SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
28 --source include/stop_slave.inc
29 SET GLOBAL slave_parallel_threads=10;
30 CHANGE MASTER TO master_use_gtid=slave_pos;
31 SET @old_parallel_mode=@@GLOBAL.slave_parallel_mode;
32 SET GLOBAL slave_parallel_mode='optimistic';
33
34
35 --connection server_4
36 --sync_with_master
37 SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
38 --source include/stop_slave.inc
39 SET GLOBAL slave_parallel_threads=10;
40 CHANGE MASTER TO master_use_gtid=slave_pos;
41 SET @old_parallel_mode=@@GLOBAL.slave_parallel_mode;
42 SET GLOBAL slave_parallel_mode='optimistic';
43
44
45 --echo *** MDEV-6676: Test that @@skip_parallel_replication is preserved in slave binlog ***
46 --connection server_1
47
48 INSERT INTO t1 VALUES(1,1);
49 BEGIN;
50 INSERT INTO t1 VALUES(2,1);
51 INSERT INTO t1 VALUES(3,1);
52 COMMIT;
53 # Do a lot of updates on same row in sequence. These would be likely to cause
54 # conflicts and rollbacks in optimistic parallel replication, but we disable
55 # that by enabling @@skip_parallel_replication. We can test that the flag is
56 # preserved down the replication hierarchy by checking that no slave retries
57 # are made.
58 SET SESSION skip_parallel_replication=1;
59 UPDATE t1 SET b=b+1 WHERE a=2;
60 UPDATE t1 SET b=b+1 WHERE a=2;
61 UPDATE t1 SET b=b+1 WHERE a=2;
62 UPDATE t1 SET b=b+1 WHERE a=2;
63 UPDATE t1 SET b=b+1 WHERE a=2;
64 UPDATE t1 SET b=b+1 WHERE a=2;
65 UPDATE t1 SET b=b+1 WHERE a=2;
66 UPDATE t1 SET b=b+1 WHERE a=2;
67 UPDATE t1 SET b=b+1 WHERE a=2;
68 UPDATE t1 SET b=b+1 WHERE a=2;
69 SET SESSION skip_parallel_replication=0;
70 SELECT * FROM t1 ORDER BY a;
71 --source include/save_master_gtid.inc
72
73 --connection server_2
74 --let $retry1= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1)
75 --source include/start_slave.inc
76 --source include/sync_with_master_gtid.inc
77 SELECT * FROM t1 ORDER BY a;
78 --let $retry2= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1)
79 --disable_query_log
80 eval SELECT IF($retry1=$retry2, "Ok, no retry",
81 CONCAT("ERROR: ", $retry2-$retry1, " retries during replication (was ",
82 $retry1, " now ", $retry2, ")")) AS status;
83 --enable_query_log
84
85 --connection server_3
86 --let $retry1= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1)
87 --source include/start_slave.inc
88 --source include/sync_with_master_gtid.inc
89 SELECT * FROM t1 ORDER BY a;
90 --let $retry2= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1)
91 --disable_query_log
92 eval SELECT IF($retry1=$retry2, "Ok, no retry",
93 CONCAT("ERROR: ", $retry2-$retry1, " retries during replication (was ",
94 $retry1, " now ", $retry2, ")")) AS status;
95 --enable_query_log
96
97 --connection server_4
98 --let $retry1= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1)
99 --source include/start_slave.inc
100 --source include/sync_with_master_gtid.inc
101 SELECT * FROM t1 ORDER BY a;
102 --let $retry2= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1)
103 --disable_query_log
104 eval SELECT IF($retry1=$retry2, "Ok, no retry",
105 CONCAT("ERROR: ", $retry2-$retry1, " retries during replication (was ",
106 $retry1, " now ", $retry2, ")")) AS status;
107 --enable_query_log
108
109
110 --echo *** MDEV-6676: Test that the FL_WAITED flag in GTID is preserved in slave binlog ***
111
112 --connection server_2
113 --source include/stop_slave.inc
114 CHANGE MASTER TO master_use_gtid=slave_pos;
115 SET GLOBAL slave_parallel_mode='optimistic';
116
117
118 --connection server_3
119 --source include/stop_slave.inc
120 CHANGE MASTER TO master_use_gtid=slave_pos;
121 SET GLOBAL slave_parallel_mode='optimistic';
122
123
124 --connection server_4
125 --source include/stop_slave.inc
126 CHANGE MASTER TO master_use_gtid=slave_pos;
127 SET GLOBAL slave_parallel_mode='optimistic';
128
129 --connection server_1
130 # Do a lot of updates on same row in sequence. Ensure that all of these but the
131 # first have to do a lock wait on the master, setting FL_WAITED in the GTID
132 # event. This should cause all slaves to not attempt to run those updates in
133 # parallel with prior events, so that no retries are made.
134
135 BEGIN;
136 UPDATE t1 SET b=b+1 WHERE a=2;
137
138 --connect (con_temp1,127.0.0.1,root,,test,$SERVER_MYPORT_1,)
139 SET debug_sync="thd_report_wait_for SIGNAL waiting1";
140 send UPDATE t1 SET b=b+1 WHERE a=2;
141 --connection server_1
142 SET debug_sync="now WAIT_FOR waiting1";
143
144 --connect (con_temp2,127.0.0.1,root,,test,$SERVER_MYPORT_1,)
145 SET debug_sync="thd_report_wait_for SIGNAL waiting2";
146 send UPDATE t1 SET b=b+1 WHERE a=2;
147 --connection server_1
148 SET debug_sync="now WAIT_FOR waiting2";
149
150 --connect (con_temp3,127.0.0.1,root,,test,$SERVER_MYPORT_1,)
151 SET debug_sync="thd_report_wait_for SIGNAL waiting3";
152 send UPDATE t1 SET b=b+1 WHERE a=2;
153 --connection server_1
154 SET debug_sync="now WAIT_FOR waiting3";
155
156 --connect (con_temp4,127.0.0.1,root,,test,$SERVER_MYPORT_1,)
157 SET debug_sync="thd_report_wait_for SIGNAL waiting4";
158 send UPDATE t1 SET b=b+1 WHERE a=2;
159 --connection server_1
160 SET debug_sync="now WAIT_FOR waiting4";
161
162 --connect (con_temp5,127.0.0.1,root,,test,$SERVER_MYPORT_1,)
163 SET debug_sync="thd_report_wait_for SIGNAL waiting5";
164 send UPDATE t1 SET b=b+1 WHERE a=2;
165 --connection server_1
166 SET debug_sync="now WAIT_FOR waiting5";
167
168 --connect (con_temp6,127.0.0.1,root,,test,$SERVER_MYPORT_1,)
169 SET debug_sync="thd_report_wait_for SIGNAL waiting6";
170 send UPDATE t1 SET b=b+1 WHERE a=2;
171 --connection server_1
172 SET debug_sync="now WAIT_FOR waiting6";
173
174 --connect (con_temp7,127.0.0.1,root,,test,$SERVER_MYPORT_1,)
175 SET debug_sync="thd_report_wait_for SIGNAL waiting7";
176 send UPDATE t1 SET b=b+1 WHERE a=2;
177 --connection server_1
178 SET debug_sync="now WAIT_FOR waiting7";
179
180 --connect (con_temp8,127.0.0.1,root,,test,$SERVER_MYPORT_1,)
181 SET debug_sync="thd_report_wait_for SIGNAL waiting8";
182 send UPDATE t1 SET b=b+1 WHERE a=2;
183 --connection server_1
184 SET debug_sync="now WAIT_FOR waiting8";
185
186 COMMIT;
187 SET debug_sync="RESET";
188
189 --connection con_temp1
190 reap;
191
192 COMMIT;
193 --connection con_temp2
194 reap;
195
196 COMMIT;
197 --connection con_temp3
198 reap;
199
200 COMMIT;
201 --connection con_temp4
202 reap;
203
204 COMMIT;
205 --connection con_temp5
206 reap;
207
208 COMMIT;
209 --connection con_temp6
210 reap;
211
212 COMMIT;
213 --connection con_temp7
214 reap;
215
216 COMMIT;
217 --connection con_temp8
218 reap;
219
220 --connection server_1
221 SELECT * FROM t1 ORDER BY a;
222 --source include/save_master_gtid.inc
223
224 --connection server_2
225 --let $retry1= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1)
226 --source include/start_slave.inc
227 --source include/sync_with_master_gtid.inc
228 SELECT * FROM t1 ORDER BY a;
229 --let $retry2= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1)
230 --disable_query_log
231 eval SELECT IF($retry1=$retry2, "Ok, no retry",
232 CONCAT("ERROR: ", $retry2-$retry1, " retries during replication (was ",
233 $retry1, " now ", $retry2, ")")) AS status;
234 --enable_query_log
235
236 --connection server_3
237 --let $retry1= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1)
238 --source include/start_slave.inc
239 --source include/sync_with_master_gtid.inc
240 SELECT * FROM t1 ORDER BY a;
241 --let $retry2= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1)
242 --disable_query_log
243 eval SELECT IF($retry1=$retry2, "Ok, no retry",
244 CONCAT("ERROR: ", $retry2-$retry1, " retries during replication (was ",
245 $retry1, " now ", $retry2, ")")) AS status;
246 --enable_query_log
247
248 --connection server_4
249 --let $retry1= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1)
250 --source include/start_slave.inc
251 --source include/sync_with_master_gtid.inc
252 SELECT * FROM t1 ORDER BY a;
253 --let $retry2= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1)
254 --disable_query_log
255 eval SELECT IF($retry1=$retry2, "Ok, no retry",
256 CONCAT("ERROR: ", $retry2-$retry1, " retries during replication (was ",
257 $retry1, " now ", $retry2, ")")) AS status;
258 --enable_query_log
259
260
261 # Clean up
262
263 --connection server_2
264 --source include/stop_slave.inc
265 SET GLOBAL slave_parallel_mode=@old_parallel_mode;
266 SET GLOBAL slave_parallel_threads=@old_parallel_threads;
267 --source include/start_slave.inc
268
269 --connection server_3
270 --source include/stop_slave.inc
271 SET GLOBAL slave_parallel_mode=@old_parallel_mode;
272 SET GLOBAL slave_parallel_threads=@old_parallel_threads;
273 --source include/start_slave.inc
274
275 --connection server_4
276 --source include/stop_slave.inc
277 SET GLOBAL slave_parallel_mode=@old_parallel_mode;
278 SET GLOBAL slave_parallel_threads=@old_parallel_threads;
279 --source include/start_slave.inc
280
281 --connection server_1
282 DROP TABLE t1;
283
284 --source include/rpl_end.inc