1include/master-slave.inc
2[connection master]
3connection server_2;
4SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
5SET GLOBAL slave_parallel_threads=10;
6ERROR HY000: This operation cannot be performed as you have a running slave ''; run STOP SLAVE '' first
7include/stop_slave.inc
8SET GLOBAL slave_parallel_threads=10;
9SELECT IF(COUNT(*) < 10, "OK", CONCAT("Found too many system user processes: ", COUNT(*))) FROM information_schema.processlist WHERE user = "system user";
10IF(COUNT(*) < 10, "OK", CONCAT("Found too many system user processes: ", COUNT(*)))
11OK
12CHANGE MASTER TO master_use_gtid=slave_pos;
13include/start_slave.inc
14SELECT IF(COUNT(*) >= 10, "OK", CONCAT("Found too few system user processes: ", COUNT(*))) FROM information_schema.processlist WHERE user = "system user";
15IF(COUNT(*) >= 10, "OK", CONCAT("Found too few system user processes: ", COUNT(*)))
16OK
17include/stop_slave.inc
18SELECT IF(COUNT(*) < 10, "OK", CONCAT("Found too many system user processes: ", COUNT(*))) FROM information_schema.processlist WHERE user = "system user";
19IF(COUNT(*) < 10, "OK", CONCAT("Found too many system user processes: ", COUNT(*)))
20OK
21include/start_slave.inc
22SELECT IF(COUNT(*) >= 10, "OK", CONCAT("Found too few system user processes: ", COUNT(*))) FROM information_schema.processlist WHERE user = "system user";
23IF(COUNT(*) >= 10, "OK", CONCAT("Found too few system user processes: ", COUNT(*)))
24OK
25*** Test long-running query in domain 1 can run in parallel with short queries in domain 0 ***
26connection server_1;
27ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
28CREATE TABLE t1 (a int PRIMARY KEY) ENGINE=MyISAM;
29CREATE TABLE t2 (a int PRIMARY KEY) ENGINE=InnoDB;
30INSERT INTO t1 VALUES (1);
31INSERT INTO t2 VALUES (1);
32connection server_2;
33connect  con_temp1,127.0.0.1,root,,test,$SERVER_MYPORT_2,;
34LOCK TABLE t1 WRITE;
35connection server_1;
36SET gtid_domain_id=1;
37INSERT INTO t1 VALUES (2);
38SET gtid_domain_id=0;
39INSERT INTO t2 VALUES (2);
40INSERT INTO t2 VALUES (3);
41BEGIN;
42INSERT INTO t2 VALUES (4);
43INSERT INTO t2 VALUES (5);
44COMMIT;
45INSERT INTO t2 VALUES (6);
46connection server_2;
47SELECT * FROM t2 ORDER by a;
48a
491
502
513
524
535
546
55connection con_temp1;
56SELECT * FROM t1;
57a
581
59UNLOCK TABLES;
60connection server_2;
61SELECT * FROM t1 ORDER BY a;
62a
631
642
65*** Test two transactions in different domains committed in opposite order on slave but in a single group commit. ***
66connection server_2;
67include/stop_slave.inc
68connection server_1;
69SET sql_log_bin=0;
70CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
71RETURNS INT DETERMINISTIC
72BEGIN
73RETURN x;
74END
75||
76SET sql_log_bin=1;
77SET @old_format= @@SESSION.binlog_format;
78SET binlog_format='statement';
79SET gtid_domain_id=1;
80INSERT INTO t2 VALUES (foo(10,
81'commit_before_enqueue SIGNAL ready1 WAIT_FOR cont1',
82'commit_after_release_LOCK_prepare_ordered SIGNAL ready2'));
83connection server_2;
84FLUSH LOGS;
85SET sql_log_bin=0;
86CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
87RETURNS INT DETERMINISTIC
88BEGIN
89IF d1 != '' THEN
90SET debug_sync = d1;
91END IF;
92IF d2 != '' THEN
93SET debug_sync = d2;
94END IF;
95RETURN x;
96END
97||
98SET sql_log_bin=1;
99SET @old_format=@@GLOBAL.binlog_format;
100SET GLOBAL binlog_format=statement;
101SET GLOBAL slave_parallel_threads=0;
102SET GLOBAL slave_parallel_threads=10;
103include/start_slave.inc
104SET debug_sync='now WAIT_FOR ready1';
105connection server_1;
106SET gtid_domain_id=2;
107INSERT INTO t2 VALUES (foo(11,
108'commit_before_enqueue SIGNAL ready3 WAIT_FOR cont3',
109'commit_after_release_LOCK_prepare_ordered SIGNAL ready4 WAIT_FOR cont4'));
110SET gtid_domain_id=0;
111SELECT * FROM t2 WHERE a >= 10 ORDER BY a;
112a
11310
11411
115connection server_2;
116SET debug_sync='now WAIT_FOR ready3';
117SET debug_sync='now SIGNAL cont3';
118SET debug_sync='now WAIT_FOR ready4';
119SET debug_sync='now SIGNAL cont1';
120SET debug_sync='now WAIT_FOR ready2';
121SET debug_sync='now SIGNAL cont4';
122SELECT * FROM t2 WHERE a >= 10 ORDER BY a;
123a
12410
12511
126include/show_binlog_events.inc
127Log_name	Pos	Event_type	Server_id	End_log_pos	Info
128slave-bin.000002	#	Binlog_checkpoint	#	#	slave-bin.000002
129slave-bin.000002	#	Gtid	#	#	BEGIN GTID #-#-# cid=#
130slave-bin.000002	#	Query	#	#	use `test`; INSERT INTO t2 VALUES (foo(11,
131'commit_before_enqueue SIGNAL ready3 WAIT_FOR cont3',
132'commit_after_release_LOCK_prepare_ordered SIGNAL ready4 WAIT_FOR cont4'))
133slave-bin.000002	#	Xid	#	#	COMMIT /* XID */
134slave-bin.000002	#	Gtid	#	#	BEGIN GTID #-#-# cid=#
135slave-bin.000002	#	Query	#	#	use `test`; INSERT INTO t2 VALUES (foo(10,
136'commit_before_enqueue SIGNAL ready1 WAIT_FOR cont1',
137'commit_after_release_LOCK_prepare_ordered SIGNAL ready2'))
138slave-bin.000002	#	Xid	#	#	COMMIT /* XID */
139FLUSH LOGS;
140connection server_2;
141include/stop_slave.inc
142SET GLOBAL slave_parallel_threads=0;
143SET GLOBAL slave_parallel_threads=10;
144SET debug_sync='RESET';
145include/start_slave.inc
146*** Test that group-committed transactions on the master can replicate in parallel on the slave. ***
147connection server_1;
148SET debug_sync='RESET';
149FLUSH LOGS;
150CREATE TABLE t3 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
151INSERT INTO t3 VALUES (1,1), (3,3), (5,5), (7,7);
152connection server_2;
153connection con_temp1;
154BEGIN;
155INSERT INTO t3 VALUES (2,102);
156connect  con_temp2,127.0.0.1,root,,test,$SERVER_MYPORT_2,;
157BEGIN;
158INSERT INTO t3 VALUES (4,104);
159connect  con_temp3,127.0.0.1,root,,test,$SERVER_MYPORT_1,;
160SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1';
161SET binlog_format=statement;
162INSERT INTO t3 VALUES (2, foo(12,
163'commit_after_release_LOCK_prepare_ordered SIGNAL slave_queued1 WAIT_FOR slave_cont1',
164''));
165connection server_1;
166SET debug_sync='now WAIT_FOR master_queued1';
167connect  con_temp4,127.0.0.1,root,,test,$SERVER_MYPORT_1,;
168SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2';
169SET binlog_format=statement;
170INSERT INTO t3 VALUES (4, foo(14,
171'commit_after_release_LOCK_prepare_ordered SIGNAL slave_queued2',
172''));
173connection server_1;
174SET debug_sync='now WAIT_FOR master_queued2';
175connect  con_temp5,127.0.0.1,root,,test,$SERVER_MYPORT_1,;
176SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued3';
177SET binlog_format=statement;
178INSERT INTO t3 VALUES (6, foo(16,
179'group_commit_waiting_for_prior SIGNAL slave_queued3',
180''));
181connection server_1;
182SET debug_sync='now WAIT_FOR master_queued3';
183SET debug_sync='now SIGNAL master_cont1';
184connection con_temp3;
185connection con_temp4;
186connection con_temp5;
187SET debug_sync='RESET';
188connection server_1;
189SELECT * FROM t3 ORDER BY a;
190a	b
1911	1
1922	12
1933	3
1944	14
1955	5
1966	16
1977	7
198include/show_binlog_events.inc
199Log_name	Pos	Event_type	Server_id	End_log_pos	Info
200master-bin.000002	#	Binlog_checkpoint	#	#	master-bin.000002
201master-bin.000002	#	Gtid	#	#	GTID #-#-#
202master-bin.000002	#	Query	#	#	use `test`; CREATE TABLE t3 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB
203master-bin.000002	#	Gtid	#	#	BEGIN GTID #-#-#
204master-bin.000002	#	Query	#	#	use `test`; INSERT INTO t3 VALUES (1,1), (3,3), (5,5), (7,7)
205master-bin.000002	#	Xid	#	#	COMMIT /* XID */
206master-bin.000002	#	Gtid	#	#	BEGIN GTID #-#-# cid=#
207master-bin.000002	#	Query	#	#	use `test`; INSERT INTO t3 VALUES (2, foo(12,
208'commit_after_release_LOCK_prepare_ordered SIGNAL slave_queued1 WAIT_FOR slave_cont1',
209''))
210master-bin.000002	#	Xid	#	#	COMMIT /* XID */
211master-bin.000002	#	Gtid	#	#	BEGIN GTID #-#-# cid=#
212master-bin.000002	#	Query	#	#	use `test`; INSERT INTO t3 VALUES (4, foo(14,
213'commit_after_release_LOCK_prepare_ordered SIGNAL slave_queued2',
214''))
215master-bin.000002	#	Xid	#	#	COMMIT /* XID */
216master-bin.000002	#	Gtid	#	#	BEGIN GTID #-#-# cid=#
217master-bin.000002	#	Query	#	#	use `test`; INSERT INTO t3 VALUES (6, foo(16,
218'group_commit_waiting_for_prior SIGNAL slave_queued3',
219''))
220master-bin.000002	#	Xid	#	#	COMMIT /* XID */
221connection server_2;
222SET debug_sync='now WAIT_FOR slave_queued3';
223connection con_temp1;
224ROLLBACK;
225connection server_2;
226SET debug_sync='now WAIT_FOR slave_queued1';
227connection con_temp2;
228ROLLBACK;
229connection server_2;
230SET debug_sync='now WAIT_FOR slave_queued2';
231SET debug_sync='now SIGNAL slave_cont1';
232SELECT * FROM t3 ORDER BY a;
233a	b
2341	1
2352	12
2363	3
2374	14
2385	5
2396	16
2407	7
241include/show_binlog_events.inc
242Log_name	Pos	Event_type	Server_id	End_log_pos	Info
243slave-bin.000003	#	Binlog_checkpoint	#	#	slave-bin.000003
244slave-bin.000003	#	Gtid	#	#	GTID #-#-#
245slave-bin.000003	#	Query	#	#	use `test`; CREATE TABLE t3 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB
246slave-bin.000003	#	Gtid	#	#	BEGIN GTID #-#-#
247slave-bin.000003	#	Query	#	#	use `test`; INSERT INTO t3 VALUES (1,1), (3,3), (5,5), (7,7)
248slave-bin.000003	#	Xid	#	#	COMMIT /* XID */
249slave-bin.000003	#	Gtid	#	#	BEGIN GTID #-#-# cid=#
250slave-bin.000003	#	Query	#	#	use `test`; INSERT INTO t3 VALUES (2, foo(12,
251'commit_after_release_LOCK_prepare_ordered SIGNAL slave_queued1 WAIT_FOR slave_cont1',
252''))
253slave-bin.000003	#	Xid	#	#	COMMIT /* XID */
254slave-bin.000003	#	Gtid	#	#	BEGIN GTID #-#-# cid=#
255slave-bin.000003	#	Query	#	#	use `test`; INSERT INTO t3 VALUES (4, foo(14,
256'commit_after_release_LOCK_prepare_ordered SIGNAL slave_queued2',
257''))
258slave-bin.000003	#	Xid	#	#	COMMIT /* XID */
259slave-bin.000003	#	Gtid	#	#	BEGIN GTID #-#-# cid=#
260slave-bin.000003	#	Query	#	#	use `test`; INSERT INTO t3 VALUES (6, foo(16,
261'group_commit_waiting_for_prior SIGNAL slave_queued3',
262''))
263slave-bin.000003	#	Xid	#	#	COMMIT /* XID */
264*** Test STOP SLAVE in parallel mode ***
265connection server_2;
266include/stop_slave.inc
267SET debug_sync='RESET';
268SET GLOBAL slave_parallel_threads=0;
269SET GLOBAL slave_parallel_threads=10;
270connection server_1;
271SET binlog_direct_non_transactional_updates=0;
272SET sql_log_bin=0;
273CALL mtr.add_suppression("Statement is unsafe because it accesses a non-transactional table after accessing a transactional table within the same transaction");
274SET sql_log_bin=1;
275BEGIN;
276INSERT INTO t2 VALUES (20);
277INSERT INTO t1 VALUES (20);
278INSERT INTO t2 VALUES (21);
279INSERT INTO t3 VALUES (20, 20);
280COMMIT;
281INSERT INTO t3 VALUES(21, 21);
282INSERT INTO t3 VALUES(22, 22);
283SET binlog_format=@old_format;
284connection con_temp1;
285BEGIN;
286INSERT INTO t2 VALUES (21);
287connection server_2;
288START SLAVE;
289connection con_temp2;
290SET @old_dbug= @@GLOBAL.debug_dbug;
291SET GLOBAL debug_dbug="+d,rpl_parallel_wait_for_done_trigger";
292STOP SLAVE;
293connection con_temp1;
294SET debug_sync='now WAIT_FOR wait_for_done_waiting';
295ROLLBACK;
296connection con_temp2;
297SET GLOBAL debug_dbug=@old_dbug;
298SET debug_sync='RESET';
299connection server_2;
300include/wait_for_slave_to_stop.inc
301SELECT * FROM t1 WHERE a >= 20 ORDER BY a;
302a
30320
304SELECT * FROM t2 WHERE a >= 20 ORDER BY a;
305a
30620
30721
308SELECT * FROM t3 WHERE a >= 20 ORDER BY a;
309a	b
31020	20
311include/start_slave.inc
312SELECT * FROM t1 WHERE a >= 20 ORDER BY a;
313a
31420
315SELECT * FROM t2 WHERE a >= 20 ORDER BY a;
316a
31720
31821
319SELECT * FROM t3 WHERE a >= 20 ORDER BY a;
320a	b
32120	20
32221	21
32322	22
324connection server_2;
325include/stop_slave.inc
326SET GLOBAL binlog_format=@old_format;
327SET GLOBAL slave_parallel_threads=0;
328SET GLOBAL slave_parallel_threads=10;
329include/start_slave.inc
330*** Test killing slave threads at various wait points ***
331*** 1. Test killing transaction waiting in commit for previous transaction to commit ***
332connection con_temp3;
333SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1';
334SET binlog_format=statement;
335INSERT INTO t3 VALUES (31, foo(31,
336'commit_before_prepare_ordered WAIT_FOR t2_waiting',
337'commit_after_prepare_ordered SIGNAL t1_ready WAIT_FOR t1_cont'));
338connection server_1;
339SET debug_sync='now WAIT_FOR master_queued1';
340connection con_temp4;
341SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2';
342SET binlog_format=statement;
343BEGIN;
344INSERT INTO t3 VALUES (32, foo(32,
345'ha_write_row_end SIGNAL t2_query WAIT_FOR t2_cont',
346''));
347INSERT INTO t3 VALUES (33, foo(33,
348'group_commit_waiting_for_prior SIGNAL t2_waiting',
349'group_commit_waiting_for_prior_killed SIGNAL t2_killed'));
350COMMIT;
351connection server_1;
352SET debug_sync='now WAIT_FOR master_queued2';
353connection con_temp5;
354SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued3';
355SET binlog_format=statement;
356INSERT INTO t3 VALUES (34, foo(34,
357'',
358''));
359connection server_1;
360SET debug_sync='now WAIT_FOR master_queued3';
361SET debug_sync='now SIGNAL master_cont1';
362connection con_temp3;
363connection con_temp4;
364connection con_temp5;
365connection server_1;
366SELECT * FROM t3 WHERE a >= 30 ORDER BY a;
367a	b
36831	31
36932	32
37033	33
37134	34
372SET debug_sync='RESET';
373connection server_2;
374SET sql_log_bin=0;
375CALL mtr.add_suppression("Query execution was interrupted");
376CALL mtr.add_suppression("Commit failed due to failure of an earlier commit on which this one depends");
377CALL mtr.add_suppression("Slave: Connection was killed");
378SET sql_log_bin=1;
379SET debug_sync='now WAIT_FOR t2_query';
380SET debug_sync='now SIGNAL t2_cont';
381SET debug_sync='now WAIT_FOR t1_ready';
382KILL THD_ID;
383SET debug_sync='now WAIT_FOR t2_killed';
384SET debug_sync='now SIGNAL t1_cont';
385include/wait_for_slave_sql_error.inc [errno=1317,1927,1964]
386STOP SLAVE IO_THREAD;
387SELECT * FROM t3 WHERE a >= 30 ORDER BY a;
388a	b
38931	31
390SET debug_sync='RESET';
391SET GLOBAL slave_parallel_threads=0;
392SET GLOBAL slave_parallel_threads=10;
393SET sql_log_bin=0;
394DROP FUNCTION foo;
395CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
396RETURNS INT DETERMINISTIC
397BEGIN
398RETURN x;
399END
400||
401SET sql_log_bin=1;
402connection server_1;
403INSERT INTO t3 VALUES (39,0);
404connection server_2;
405include/start_slave.inc
406SELECT * FROM t3 WHERE a >= 30 ORDER BY a;
407a	b
40831	31
40932	32
41033	33
41134	34
41239	0
413SET sql_log_bin=0;
414DROP FUNCTION foo;
415CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
416RETURNS INT DETERMINISTIC
417BEGIN
418IF d1 != '' THEN
419SET debug_sync = d1;
420END IF;
421IF d2 != '' THEN
422SET debug_sync = d2;
423END IF;
424RETURN x;
425END
426||
427SET sql_log_bin=1;
428connection server_2;
429include/stop_slave.inc
430SET GLOBAL binlog_format=@old_format;
431SET GLOBAL slave_parallel_threads=0;
432SET GLOBAL slave_parallel_threads=10;
433include/start_slave.inc
434*** 2. Same as (1), but without restarting IO thread after kill of SQL threads ***
435connection con_temp3;
436SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1';
437SET binlog_format=statement;
438INSERT INTO t3 VALUES (41, foo(41,
439'commit_before_prepare_ordered WAIT_FOR t2_waiting',
440'commit_after_prepare_ordered SIGNAL t1_ready WAIT_FOR t1_cont'));
441connection server_1;
442SET debug_sync='now WAIT_FOR master_queued1';
443connection con_temp4;
444SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2';
445SET binlog_format=statement;
446BEGIN;
447INSERT INTO t3 VALUES (42, foo(42,
448'ha_write_row_end SIGNAL t2_query WAIT_FOR t2_cont',
449''));
450INSERT INTO t3 VALUES (43, foo(43,
451'group_commit_waiting_for_prior SIGNAL t2_waiting',
452'group_commit_waiting_for_prior_killed SIGNAL t2_killed'));
453COMMIT;
454connection server_1;
455SET debug_sync='now WAIT_FOR master_queued2';
456connection con_temp5;
457SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued3';
458SET binlog_format=statement;
459INSERT INTO t3 VALUES (44, foo(44,
460'',
461''));
462connection server_1;
463SET debug_sync='now WAIT_FOR master_queued3';
464SET debug_sync='now SIGNAL master_cont1';
465connection con_temp3;
466connection con_temp4;
467connection con_temp5;
468connection server_1;
469SELECT * FROM t3 WHERE a >= 40 ORDER BY a;
470a	b
47141	41
47242	42
47343	43
47444	44
475SET debug_sync='RESET';
476connection server_2;
477SET debug_sync='now WAIT_FOR t2_query';
478SET debug_sync='now SIGNAL t2_cont';
479SET debug_sync='now WAIT_FOR t1_ready';
480KILL THD_ID;
481SET debug_sync='now WAIT_FOR t2_killed';
482SET debug_sync='now SIGNAL t1_cont';
483include/wait_for_slave_sql_error.inc [errno=1317,1927,1964]
484SET debug_sync='RESET';
485SET GLOBAL slave_parallel_threads=0;
486SET GLOBAL slave_parallel_threads=10;
487SET sql_log_bin=0;
488DROP FUNCTION foo;
489CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
490RETURNS INT DETERMINISTIC
491BEGIN
492RETURN x;
493END
494||
495SET sql_log_bin=1;
496connection server_1;
497INSERT INTO t3 VALUES (49,0);
498connection server_2;
499START SLAVE SQL_THREAD;
500SELECT * FROM t3 WHERE a >= 40 ORDER BY a;
501a	b
50241	41
50342	42
50443	43
50544	44
50649	0
507SET sql_log_bin=0;
508DROP FUNCTION foo;
509CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
510RETURNS INT DETERMINISTIC
511BEGIN
512IF d1 != '' THEN
513SET debug_sync = d1;
514END IF;
515IF d2 != '' THEN
516SET debug_sync = d2;
517END IF;
518RETURN x;
519END
520||
521SET sql_log_bin=1;
522connection server_2;
523include/stop_slave.inc
524SET GLOBAL binlog_format=@old_format;
525SET GLOBAL slave_parallel_threads=0;
526SET GLOBAL slave_parallel_threads=10;
527include/start_slave.inc
528*** 3. Same as (2), but not using gtid mode ***
529connection server_2;
530include/stop_slave.inc
531CHANGE MASTER TO master_use_gtid=no;
532include/start_slave.inc
533connection server_1;
534connection con_temp3;
535SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1';
536SET binlog_format=statement;
537INSERT INTO t3 VALUES (51, foo(51,
538'commit_before_prepare_ordered WAIT_FOR t2_waiting',
539'commit_after_prepare_ordered SIGNAL t1_ready WAIT_FOR t1_cont'));
540connection server_1;
541SET debug_sync='now WAIT_FOR master_queued1';
542connection con_temp4;
543SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2';
544SET binlog_format=statement;
545BEGIN;
546INSERT INTO t3 VALUES (52, foo(52,
547'ha_write_row_end SIGNAL t2_query WAIT_FOR t2_cont',
548''));
549INSERT INTO t3 VALUES (53, foo(53,
550'group_commit_waiting_for_prior SIGNAL t2_waiting',
551'group_commit_waiting_for_prior_killed SIGNAL t2_killed'));
552COMMIT;
553connection server_1;
554SET debug_sync='now WAIT_FOR master_queued2';
555connection con_temp5;
556SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued3';
557SET binlog_format=statement;
558INSERT INTO t3 VALUES (54, foo(54,
559'',
560''));
561connection server_1;
562SET debug_sync='now WAIT_FOR master_queued3';
563SET debug_sync='now SIGNAL master_cont1';
564connection con_temp3;
565connection con_temp4;
566connection con_temp5;
567connection server_1;
568SELECT * FROM t3 WHERE a >= 50 ORDER BY a;
569a	b
57051	51
57152	52
57253	53
57354	54
574SET debug_sync='RESET';
575connection server_2;
576SET debug_sync='now WAIT_FOR t2_query';
577SET debug_sync='now SIGNAL t2_cont';
578SET debug_sync='now WAIT_FOR t1_ready';
579KILL THD_ID;
580SET debug_sync='now WAIT_FOR t2_killed';
581SET debug_sync='now SIGNAL t1_cont';
582include/wait_for_slave_sql_error.inc [errno=1317,1927,1964]
583SELECT * FROM t3 WHERE a >= 50 ORDER BY a;
584a	b
58551	51
586SET debug_sync='RESET';
587SET GLOBAL slave_parallel_threads=0;
588SET GLOBAL slave_parallel_threads=10;
589SET sql_log_bin=0;
590DROP FUNCTION foo;
591CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
592RETURNS INT DETERMINISTIC
593BEGIN
594RETURN x;
595END
596||
597SET sql_log_bin=1;
598connection server_1;
599INSERT INTO t3 VALUES (59,0);
600connection server_2;
601START SLAVE SQL_THREAD;
602SELECT * FROM t3 WHERE a >= 50 ORDER BY a;
603a	b
60451	51
60552	52
60653	53
60754	54
60859	0
609SET sql_log_bin=0;
610DROP FUNCTION foo;
611CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
612RETURNS INT DETERMINISTIC
613BEGIN
614IF d1 != '' THEN
615SET debug_sync = d1;
616END IF;
617IF d2 != '' THEN
618SET debug_sync = d2;
619END IF;
620RETURN x;
621END
622||
623SET sql_log_bin=1;
624include/stop_slave.inc
625CHANGE MASTER TO master_use_gtid=slave_pos;
626include/start_slave.inc
627connection server_2;
628include/stop_slave.inc
629SET GLOBAL binlog_format=@old_format;
630SET GLOBAL slave_parallel_threads=0;
631SET GLOBAL slave_parallel_threads=4;
632include/start_slave.inc
633*** 4. Test killing thread that is waiting to start transaction until previous transaction commits ***
634connection server_1;
635SET binlog_format=statement;
636SET gtid_domain_id=2;
637BEGIN;
638INSERT INTO t3 VALUES (70, foo(70,
639'rpl_parallel_start_waiting_for_prior SIGNAL t4_waiting', ''));
640INSERT INTO t3 VALUES (60, foo(60,
641'ha_write_row_end SIGNAL d2_query WAIT_FOR d2_cont2',
642'rpl_parallel_end_of_group SIGNAL d2_done WAIT_FOR d2_cont'));
643COMMIT;
644SET gtid_domain_id=0;
645connection server_2;
646SET debug_sync='now WAIT_FOR d2_query';
647connection server_1;
648SET gtid_domain_id=1;
649BEGIN;
650INSERT INTO t3 VALUES (61, foo(61,
651'rpl_parallel_start_waiting_for_prior SIGNAL t3_waiting',
652'rpl_parallel_start_waiting_for_prior_killed SIGNAL t3_killed'));
653INSERT INTO t3 VALUES (62, foo(62,
654'ha_write_row_end SIGNAL d1_query WAIT_FOR d1_cont2',
655'rpl_parallel_end_of_group SIGNAL d1_done WAIT_FOR d1_cont'));
656COMMIT;
657SET gtid_domain_id=0;
658connection server_2;
659SET debug_sync='now WAIT_FOR d1_query';
660connection server_1;
661SET gtid_domain_id=0;
662INSERT INTO t3 VALUES (63, foo(63,
663'ha_write_row_end SIGNAL d0_query WAIT_FOR d0_cont2',
664'rpl_parallel_end_of_group SIGNAL d0_done WAIT_FOR d0_cont'));
665connection server_2;
666SET debug_sync='now WAIT_FOR d0_query';
667connection server_1;
668SET gtid_domain_id=3;
669BEGIN;
670INSERT INTO t3 VALUES (68, foo(68,
671'rpl_parallel_start_waiting_for_prior SIGNAL t2_waiting', ''));
672INSERT INTO t3 VALUES (69, foo(69,
673'ha_write_row_end SIGNAL d3_query WAIT_FOR d3_cont2',
674'rpl_parallel_end_of_group SIGNAL d3_done WAIT_FOR d3_cont'));
675COMMIT;
676SET gtid_domain_id=0;
677connection server_2;
678SET debug_sync='now WAIT_FOR d3_query';
679SET debug_sync='now SIGNAL d2_cont2';
680SET debug_sync='now WAIT_FOR d2_done';
681SET debug_sync='now SIGNAL d1_cont2';
682SET debug_sync='now WAIT_FOR d1_done';
683SET debug_sync='now SIGNAL d0_cont2';
684SET debug_sync='now WAIT_FOR d0_done';
685SET debug_sync='now SIGNAL d3_cont2';
686SET debug_sync='now WAIT_FOR d3_done';
687connection con_temp3;
688SET binlog_format=statement;
689INSERT INTO t3 VALUES (64, foo(64,
690'rpl_parallel_before_mark_start_commit SIGNAL t1_waiting WAIT_FOR t1_cont', ''));
691SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2 WAIT_FOR master_cont2';
692INSERT INTO t3 VALUES (65, foo(65, '', ''));
693connection server_1;
694SET debug_sync='now WAIT_FOR master_queued2';
695connection con_temp4;
696SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued3';
697INSERT INTO t3 VALUES (66, foo(66, '', ''));
698connection server_1;
699SET debug_sync='now WAIT_FOR master_queued3';
700connection con_temp5;
701SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued4';
702INSERT INTO t3 VALUES (67, foo(67, '', ''));
703connection server_1;
704SET debug_sync='now WAIT_FOR master_queued4';
705SET debug_sync='now SIGNAL master_cont2';
706connection con_temp3;
707connection con_temp4;
708connection con_temp5;
709connection server_1;
710SELECT * FROM t3 WHERE a >= 60 ORDER BY a;
711a	b
71260	60
71361	61
71462	62
71563	63
71664	64
71765	65
71866	66
71967	67
72068	68
72169	69
72270	70
723SET debug_sync='RESET';
724connection server_2;
725SET debug_sync='now SIGNAL d0_cont';
726SET debug_sync='now WAIT_FOR t1_waiting';
727SET debug_sync='now SIGNAL d3_cont';
728SET debug_sync='now WAIT_FOR t2_waiting';
729SET debug_sync='now SIGNAL d1_cont';
730SET debug_sync='now WAIT_FOR t3_waiting';
731SET debug_sync='now SIGNAL d2_cont';
732SET debug_sync='now WAIT_FOR t4_waiting';
733KILL THD_ID;
734SET debug_sync='now WAIT_FOR t3_killed';
735SET debug_sync='now SIGNAL t1_cont';
736include/wait_for_slave_sql_error.inc [errno=1317,1927,1964]
737STOP SLAVE IO_THREAD;
738SELECT * FROM t3 WHERE a >= 60 AND a != 65 ORDER BY a;
739a	b
74060	60
74161	61
74262	62
74363	63
74464	64
74568	68
74669	69
74770	70
748SET debug_sync='RESET';
749SET GLOBAL slave_parallel_threads=0;
750SET GLOBAL slave_parallel_threads=10;
751SET sql_log_bin=0;
752DROP FUNCTION foo;
753CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
754RETURNS INT DETERMINISTIC
755BEGIN
756RETURN x;
757END
758||
759SET sql_log_bin=1;
760connection server_1;
761UPDATE t3 SET b=b+1 WHERE a=60;
762connection server_2;
763include/start_slave.inc
764SELECT * FROM t3 WHERE a >= 60 ORDER BY a;
765a	b
76660	61
76761	61
76862	62
76963	63
77064	64
77165	65
77266	66
77367	67
77468	68
77569	69
77670	70
777SET sql_log_bin=0;
778DROP FUNCTION foo;
779CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
780RETURNS INT DETERMINISTIC
781BEGIN
782IF d1 != '' THEN
783SET debug_sync = d1;
784END IF;
785IF d2 != '' THEN
786SET debug_sync = d2;
787END IF;
788RETURN x;
789END
790||
791SET sql_log_bin=1;
792connection server_2;
793include/stop_slave.inc
794SET GLOBAL binlog_format=@old_format;
795SET GLOBAL slave_parallel_threads=0;
796SET GLOBAL slave_parallel_threads=10;
797include/start_slave.inc
798*** 5. Test killing thread that is waiting for queue of max length to shorten ***
799SET @old_max_queued= @@GLOBAL.slave_parallel_max_queued;
800SET GLOBAL slave_parallel_max_queued=9000;
801connection server_1;
802SET binlog_format=statement;
803INSERT INTO t3 VALUES (80, foo(0,
804'ha_write_row_end SIGNAL query_waiting WAIT_FOR query_cont', ''));
805connection server_2;
806SET debug_sync='now WAIT_FOR query_waiting';
807SET @old_dbug= @@GLOBAL.debug_dbug;
808SET GLOBAL debug_dbug="+d,rpl_parallel_wait_queue_max";
809connection server_1;
810SELECT * FROM t3 WHERE a >= 80 ORDER BY a;
811a	b
81280	0
81381	10000
814connection server_2;
815SET debug_sync='now WAIT_FOR wait_queue_ready';
816KILL THD_ID;
817SET debug_sync='now WAIT_FOR wait_queue_killed';
818SET debug_sync='now SIGNAL query_cont';
819include/wait_for_slave_sql_error.inc [errno=1317,1927,1964]
820STOP SLAVE IO_THREAD;
821SET GLOBAL debug_dbug=@old_dbug;
822SET GLOBAL slave_parallel_max_queued= @old_max_queued;
823connection server_1;
824INSERT INTO t3 VALUES (82,0);
825SET binlog_format=@old_format;
826connection server_2;
827SET debug_sync='RESET';
828include/start_slave.inc
829SELECT * FROM t3 WHERE a >= 80 ORDER BY a;
830a	b
83180	0
83281	10000
83382	0
834connection server_2;
835include/stop_slave.inc
836SET GLOBAL binlog_format=@old_format;
837SET GLOBAL slave_parallel_threads=0;
838SET GLOBAL slave_parallel_threads=10;
839include/start_slave.inc
840*** MDEV-5788 Incorrect free of rgi->deferred_events in parallel replication  ***
841connection server_2;
842include/stop_slave.inc
843SET GLOBAL replicate_ignore_table="test.t3";
844SET GLOBAL slave_parallel_threads=2;
845include/start_slave.inc
846connection server_1;
847INSERT INTO t3 VALUES (100, rand());
848INSERT INTO t3 VALUES (101, rand());
849connection server_2;
850connection server_1;
851INSERT INTO t3 VALUES (102, rand());
852INSERT INTO t3 VALUES (103, rand());
853INSERT INTO t3 VALUES (104, rand());
854INSERT INTO t3 VALUES (105, rand());
855connection server_2;
856include/stop_slave.inc
857SET GLOBAL replicate_ignore_table="";
858include/start_slave.inc
859connection server_1;
860INSERT INTO t3 VALUES (106, rand());
861INSERT INTO t3 VALUES (107, rand());
862connection server_2;
863SELECT * FROM t3 WHERE a >= 100 ORDER BY a;
864a	b
865106	#
866107	#
867*** MDEV-5921: In parallel replication, an error is not correctly signalled to the next transaction ***
868connection server_2;
869include/stop_slave.inc
870SET GLOBAL slave_parallel_threads=10;
871include/start_slave.inc
872connection server_1;
873INSERT INTO t3 VALUES (110, 1);
874connection server_2;
875SELECT * FROM t3 WHERE a >= 110 ORDER BY a;
876a	b
877110	1
878SET sql_log_bin=0;
879INSERT INTO t3 VALUES (111, 666);
880SET sql_log_bin=1;
881connection server_1;
882connect  con1,127.0.0.1,root,,test,$SERVER_MYPORT_1,;
883SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1';
884INSERT INTO t3 VALUES (111, 2);
885connection server_1;
886SET debug_sync='now WAIT_FOR master_queued1';
887connect  con2,127.0.0.1,root,,test,$SERVER_MYPORT_1,;
888SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2';
889INSERT INTO t3 VALUES (112, 3);
890connection server_1;
891SET debug_sync='now WAIT_FOR master_queued2';
892SET debug_sync='now SIGNAL master_cont1';
893connection con1;
894connection con2;
895SET debug_sync='RESET';
896connection server_2;
897include/wait_for_slave_sql_error.inc [errno=1062]
898include/wait_for_slave_sql_to_stop.inc
899SELECT * FROM t3 WHERE a >= 110 ORDER BY a;
900a	b
901110	1
902111	666
903SET sql_log_bin=0;
904DELETE FROM t3 WHERE a=111 AND b=666;
905SET sql_log_bin=1;
906START SLAVE SQL_THREAD;
907SELECT * FROM t3 WHERE a >= 110 ORDER BY a;
908a	b
909110	1
910111	2
911112	3
912***MDEV-5914: Parallel replication deadlock due to InnoDB lock conflicts ***
913connection server_2;
914include/stop_slave.inc
915connection server_1;
916CREATE TABLE t4 (a INT PRIMARY KEY, b INT, KEY b_idx(b)) ENGINE=InnoDB;
917INSERT INTO t4 VALUES (1,NULL), (2,2), (3,NULL), (4,4), (5, NULL), (6, 6);
918connection con1;
919SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1';
920UPDATE t4 SET b=NULL WHERE a=6;
921connection server_1;
922SET debug_sync='now WAIT_FOR master_queued1';
923connection con2;
924SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2';
925DELETE FROM t4 WHERE b <= 3;
926connection server_1;
927SET debug_sync='now WAIT_FOR master_queued2';
928SET debug_sync='now SIGNAL master_cont1';
929connection con1;
930connection con2;
931SET debug_sync='RESET';
932connection server_2;
933include/start_slave.inc
934include/stop_slave.inc
935SELECT * FROM t4 ORDER BY a;
936a	b
9371	NULL
9383	NULL
9394	4
9405	NULL
9416	NULL
942connection server_1;
943DELETE FROM t4;
944INSERT INTO t4 VALUES (1,NULL), (2,2), (3,NULL), (4,4), (5, NULL), (6, 6);
945connection con1;
946SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1';
947INSERT INTO t4 VALUES (7, NULL);
948connection server_1;
949SET debug_sync='now WAIT_FOR master_queued1';
950connection con2;
951SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2';
952DELETE FROM t4 WHERE b <= 3;
953connection server_1;
954SET debug_sync='now WAIT_FOR master_queued2';
955SET debug_sync='now SIGNAL master_cont1';
956connection con1;
957connection con2;
958SET debug_sync='RESET';
959connection server_2;
960include/start_slave.inc
961include/stop_slave.inc
962SELECT * FROM t4 ORDER BY a;
963a	b
9641	NULL
9653	NULL
9664	4
9675	NULL
9686	6
9697	NULL
970connection server_1;
971DELETE FROM t4;
972INSERT INTO t4 VALUES (1,NULL), (2,2), (3,NULL), (4,4), (5, NULL), (6, 6);
973connection con1;
974SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1';
975UPDATE t4 SET b=NULL WHERE a=6;
976connection server_1;
977SET debug_sync='now WAIT_FOR master_queued1';
978connection con2;
979SET @old_format= @@SESSION.binlog_format;
980SET binlog_format='statement';
981SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2';
982DELETE FROM t4 WHERE b <= 1;
983connection server_1;
984SET debug_sync='now WAIT_FOR master_queued2';
985SET debug_sync='now SIGNAL master_cont1';
986connection con1;
987connection con2;
988SET @old_format=@@GLOBAL.binlog_format;
989SET debug_sync='RESET';
990connection server_2;
991SET @old_dbug= @@GLOBAL.debug_dbug;
992SET GLOBAL debug_dbug="+d,disable_thd_need_ordering_with";
993include/start_slave.inc
994SET GLOBAL debug_dbug=@old_dbug;
995SELECT * FROM t4 ORDER BY a;
996a	b
9971	NULL
9982	2
9993	NULL
10004	4
10015	NULL
10026	NULL
1003SET @last_gtid= 'GTID';
1004SELECT IF(@@gtid_slave_pos LIKE CONCAT('%',@last_gtid,'%'), "GTID found ok",
1005CONCAT("GTID ", @last_gtid, " not found in gtid_slave_pos=", @@gtid_slave_pos))
1006AS result;
1007result
1008GTID found ok
1009SELECT "ROW FOUND" AS `Is the row found?`
1010  FROM mysql.gtid_slave_pos
1011WHERE CONCAT(domain_id, "-", server_id, "-", seq_no) = @last_gtid;
1012Is the row found?
1013ROW FOUND
1014*** MDEV-5938: Exec_master_log_pos not updated at log rotate in parallel replication ***
1015connection server_2;
1016include/stop_slave.inc
1017SET GLOBAL slave_parallel_threads=1;
1018SET DEBUG_SYNC= 'RESET';
1019include/start_slave.inc
1020connection server_1;
1021CREATE TABLE t5 (a INT PRIMARY KEY, b INT);
1022INSERT INTO t5 VALUES (1,1);
1023INSERT INTO t5 VALUES (2,2), (3,8);
1024INSERT INTO t5 VALUES (4,16);
1025connection server_2;
1026test_check
1027OK
1028test_check
1029OK
1030connection server_1;
1031FLUSH LOGS;
1032connection server_2;
1033test_check
1034OK
1035test_check
1036OK
1037*** MDEV_6435: Incorrect error handling when query binlogged partially on master with "killed" error ***
1038connection server_1;
1039CREATE TABLE t6 (a INT) ENGINE=MyISAM;
1040CREATE TRIGGER tr AFTER INSERT ON t6 FOR EACH ROW SET @a = 1;
1041connection con1;
1042SET @old_format= @@binlog_format;
1043SET binlog_format= statement;
1044SET debug_sync='sp_head_execute_before_loop SIGNAL ready WAIT_FOR cont';
1045INSERT INTO t6 VALUES (1), (2), (3);
1046connection server_1;
1047SET debug_sync='now WAIT_FOR ready';
1048KILL QUERY CONID;
1049SET debug_sync='now SIGNAL cont';
1050connection con1;
1051ERROR 70100: Query execution was interrupted
1052SET binlog_format= @old_format;
1053SET debug_sync='RESET';
1054connection server_1;
1055SET debug_sync='RESET';
1056connection server_2;
1057include/wait_for_slave_sql_error.inc [errno=1317]
1058STOP SLAVE IO_THREAD;
1059SET GLOBAL gtid_slave_pos= 'AFTER_ERROR_GTID_POS';
1060include/start_slave.inc
1061connection server_1;
1062INSERT INTO t6 VALUES (4);
1063SELECT * FROM t6 ORDER BY a;
1064a
10651
10664
1067connection server_2;
1068SELECT * FROM t6 ORDER BY a;
1069a
10704
1071*** MDEV-6551: Some replication errors are ignored if slave_parallel_threads > 0 ***
1072connection server_1;
1073INSERT INTO t2 VALUES (31);
1074include/save_master_gtid.inc
1075connection server_2;
1076include/sync_with_master_gtid.inc
1077include/stop_slave.inc
1078SET GLOBAL slave_parallel_threads= 0;
1079include/start_slave.inc
1080SET sql_log_bin= 0;
1081INSERT INTO t2 VALUES (32);
1082SET sql_log_bin= 1;
1083connection server_1;
1084INSERT INTO t2 VALUES (32);
1085FLUSH LOGS;
1086INSERT INTO t2 VALUES (33);
1087INSERT INTO t2 VALUES (34);
1088SELECT * FROM t2 WHERE a >= 30 ORDER BY a;
1089a
109031
109132
109233
109334
1094include/save_master_gtid.inc
1095connection server_2;
1096include/wait_for_slave_sql_error.inc [errno=1062]
1097connection server_2;
1098include/stop_slave_io.inc
1099SET GLOBAL slave_parallel_threads=10;
1100START SLAVE;
1101include/wait_for_slave_sql_error.inc [errno=1062]
1102START SLAVE SQL_THREAD;
1103include/wait_for_slave_sql_error.inc [errno=1062]
1104SELECT * FROM t2 WHERE a >= 30 ORDER BY a;
1105a
110631
110732
1108SET sql_slave_skip_counter= 1;
1109ERROR HY000: When using parallel replication and GTID with multiple replication domains, @@sql_slave_skip_counter can not be used. Instead, setting @@gtid_slave_pos explicitly can be used to skip to after a given GTID position
1110include/stop_slave_io.inc
1111include/start_slave.inc
1112include/sync_with_master_gtid.inc
1113SELECT * FROM t2 WHERE a >= 30 ORDER BY a;
1114a
111531
111632
111733
111834
1119*** MDEV-6775: Wrong binlog order in parallel replication ***
1120connection server_1;
1121DELETE FROM t4;
1122INSERT INTO t4 VALUES (1,NULL), (3,NULL), (4,4), (5, NULL), (6, 6);
1123include/save_master_gtid.inc
1124connection server_2;
1125include/sync_with_master_gtid.inc
1126include/stop_slave.inc
1127SET @old_dbug= @@GLOBAL.debug_dbug;
1128SET GLOBAL debug_dbug="+d,inject_binlog_commit_before_get_LOCK_log";
1129SET @old_format=@@GLOBAL.binlog_format;
1130SET GLOBAL binlog_format=ROW;
1131SET GLOBAL slave_parallel_threads=0;
1132SET GLOBAL slave_parallel_threads=10;
1133connection con1;
1134SET @old_format= @@binlog_format;
1135SET binlog_format= statement;
1136SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1';
1137UPDATE t4 SET b=NULL WHERE a=6;
1138connection server_1;
1139SET debug_sync='now WAIT_FOR master_queued1';
1140connection con2;
1141SET @old_format= @@binlog_format;
1142SET binlog_format= statement;
1143SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2';
1144DELETE FROM t4 WHERE b <= 3;
1145connection server_1;
1146SET debug_sync='now WAIT_FOR master_queued2';
1147SET debug_sync='now SIGNAL master_cont1';
1148connection con1;
1149SET binlog_format= @old_format;
1150connection con2;
1151SET binlog_format= @old_format;
1152SET debug_sync='RESET';
1153SELECT * FROM t4 ORDER BY a;
1154a	b
11551	NULL
11563	NULL
11574	4
11585	NULL
11596	NULL
1160connection server_2;
1161include/start_slave.inc
1162SET debug_sync= 'now WAIT_FOR waiting';
1163SELECT * FROM t4 ORDER BY a;
1164a	b
11651	NULL
11663	NULL
11674	4
11685	NULL
11696	NULL
1170SET debug_sync= 'now SIGNAL cont';
1171include/stop_slave.inc
1172SET GLOBAL debug_dbug=@old_dbug;
1173SET GLOBAL binlog_format= @old_format;
1174SET GLOBAL slave_parallel_threads=0;
1175SET GLOBAL slave_parallel_threads=10;
1176include/start_slave.inc
1177*** MDEV-7237: Parallel replication: incorrect relaylog position after stop/start the slave ***
1178connection server_1;
1179INSERT INTO t2 VALUES (40);
1180connection server_2;
1181include/stop_slave.inc
1182CHANGE MASTER TO master_use_gtid=no;
1183SET @old_dbug= @@GLOBAL.debug_dbug;
1184SET GLOBAL debug_dbug="+d,rpl_parallel_scheduled_gtid_0_x_100";
1185SET GLOBAL debug_dbug="+d,rpl_parallel_wait_for_done_trigger";
1186SET GLOBAL slave_parallel_threads=0;
1187SET GLOBAL slave_parallel_threads=10;
1188connection server_1;
1189INSERT INTO t2 VALUES (41);
1190INSERT INTO t2 VALUES (42);
1191SET @old_format= @@binlog_format;
1192SET binlog_format= statement;
1193DELETE FROM t2 WHERE a=40;
1194SET binlog_format= @old_format;
1195INSERT INTO t2 VALUES (43);
1196INSERT INTO t2 VALUES (44);
1197FLUSH LOGS;
1198INSERT INTO t2 VALUES (45);
1199SET gtid_seq_no=100;
1200INSERT INTO t2 VALUES (46);
1201connection con_temp2;
1202BEGIN;
1203SELECT * FROM t2 WHERE a=40 FOR UPDATE;
1204a
120540
1206connection server_2;
1207include/start_slave.inc
1208SET debug_sync= 'now WAIT_FOR scheduled_gtid_0_x_100';
1209STOP SLAVE;
1210connection con_temp2;
1211SET debug_sync= 'now WAIT_FOR wait_for_done_waiting';
1212ROLLBACK;
1213connection server_2;
1214include/wait_for_slave_sql_to_stop.inc
1215SELECT * FROM t2 WHERE a >= 40 ORDER BY a;
1216a
121741
121842
1219include/start_slave.inc
1220SELECT * FROM t2 WHERE a >= 40 ORDER BY a;
1221a
122241
122342
122443
122544
122645
122746
1228include/stop_slave.inc
1229SET GLOBAL debug_dbug=@old_dbug;
1230SET DEBUG_SYNC= 'RESET';
1231SET GLOBAL slave_parallel_threads=0;
1232SET GLOBAL slave_parallel_threads=10;
1233CHANGE MASTER TO master_use_gtid=slave_pos;
1234include/start_slave.inc
1235*** MDEV-7326 Server deadlock in connection with parallel replication ***
1236connection server_2;
1237include/stop_slave.inc
1238SET GLOBAL slave_parallel_threads=0;
1239SET GLOBAL slave_parallel_threads=3;
1240SET GLOBAL debug_dbug="+d,rpl_parallel_simulate_temp_err_xid";
1241include/start_slave.inc
1242connection server_1;
1243SET @old_format= @@SESSION.binlog_format;
1244SET binlog_format= STATEMENT;
1245INSERT INTO t1 VALUES (foo(50,
1246"rpl_parallel_start_waiting_for_prior SIGNAL t3_ready",
1247"rpl_parallel_end_of_group SIGNAL prep_ready WAIT_FOR prep_cont"));
1248connection server_2;
1249SET DEBUG_SYNC= "now WAIT_FOR prep_ready";
1250connection server_1;
1251INSERT INTO t2 VALUES (foo(50,
1252"rpl_parallel_simulate_temp_err_xid SIGNAL t1_ready1 WAIT_FOR t1_cont1",
1253"rpl_parallel_retry_after_unmark SIGNAL t1_ready2 WAIT_FOR t1_cont2"));
1254connection server_2;
1255SET DEBUG_SYNC= "now WAIT_FOR t1_ready1";
1256connection server_1;
1257INSERT INTO t1 VALUES (foo(51,
1258"rpl_parallel_before_mark_start_commit SIGNAL t2_ready1 WAIT_FOR t2_cont1",
1259"rpl_parallel_after_mark_start_commit SIGNAL t2_ready2"));
1260connection server_2;
1261SET DEBUG_SYNC= "now WAIT_FOR t2_ready1";
1262SET DEBUG_SYNC= "now SIGNAL t1_cont1";
1263SET DEBUG_SYNC= "now WAIT_FOR t1_ready2";
1264connection server_1;
1265INSERT INTO t1 VALUES (52);
1266SET BINLOG_FORMAT= @old_format;
1267SELECT * FROM t2 WHERE a>=50 ORDER BY a;
1268a
126950
1270SELECT * FROM t1 WHERE a>=50 ORDER BY a;
1271a
127250
127351
127452
1275connection server_2;
1276SET DEBUG_SYNC= "now SIGNAL prep_cont";
1277SET DEBUG_SYNC= "now WAIT_FOR t3_ready";
1278SET DEBUG_SYNC= "now SIGNAL t2_cont1";
1279SET DEBUG_SYNC= "now WAIT_FOR t2_ready2";
1280SET DEBUG_SYNC= "now SIGNAL t1_cont2";
1281connection server_1;
1282connection server_2;
1283SELECT * FROM t2 WHERE a>=50 ORDER BY a;
1284a
128550
1286SELECT * FROM t1 WHERE a>=50 ORDER BY a;
1287a
128850
128951
129052
1291SET DEBUG_SYNC="reset";
1292include/stop_slave.inc
1293SET GLOBAL debug_dbug=@old_dbug;
1294SET GLOBAL slave_parallel_threads=0;
1295SET GLOBAL slave_parallel_threads=10;
1296include/start_slave.inc
1297*** MDEV-7326 Server deadlock in connection with parallel replication ***
1298connection server_2;
1299include/stop_slave.inc
1300SET GLOBAL slave_parallel_threads=0;
1301SET GLOBAL slave_parallel_threads=3;
1302SET GLOBAL debug_dbug="+d,rpl_parallel_simulate_temp_err_xid";
1303include/start_slave.inc
1304connection server_1;
1305SET @old_format= @@SESSION.binlog_format;
1306SET binlog_format= STATEMENT;
1307INSERT INTO t1 VALUES (foo(60,
1308"rpl_parallel_start_waiting_for_prior SIGNAL t3_ready",
1309"rpl_parallel_end_of_group SIGNAL prep_ready WAIT_FOR prep_cont"));
1310connection server_2;
1311SET DEBUG_SYNC= "now WAIT_FOR prep_ready";
1312connection server_1;
1313INSERT INTO t2 VALUES (foo(60,
1314"rpl_parallel_simulate_temp_err_xid SIGNAL t1_ready1 WAIT_FOR t1_cont1",
1315"rpl_parallel_retry_after_unmark SIGNAL t1_ready2 WAIT_FOR t1_cont2"));
1316connection server_2;
1317SET DEBUG_SYNC= "now WAIT_FOR t1_ready1";
1318connection con_temp3;
1319SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1';
1320SET binlog_format=statement;
1321INSERT INTO t1 VALUES (foo(61,
1322"rpl_parallel_before_mark_start_commit SIGNAL t2_ready1 WAIT_FOR t2_cont1",
1323"rpl_parallel_after_mark_start_commit SIGNAL t2_ready2"));
1324connection server_1;
1325SET debug_sync='now WAIT_FOR master_queued1';
1326connection con_temp4;
1327SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2';
1328INSERT INTO t6 VALUES (62);
1329connection server_1;
1330SET debug_sync='now WAIT_FOR master_queued2';
1331SET debug_sync='now SIGNAL master_cont1';
1332connection con_temp3;
1333connection con_temp4;
1334connection server_1;
1335SET debug_sync='RESET';
1336SET BINLOG_FORMAT= @old_format;
1337SELECT * FROM t2 WHERE a>=60 ORDER BY a;
1338a
133960
1340SELECT * FROM t1 WHERE a>=60 ORDER BY a;
1341a
134260
134361
1344SELECT * FROM t6 WHERE a>=60 ORDER BY a;
1345a
134662
1347connection server_2;
1348SET DEBUG_SYNC= "now WAIT_FOR t2_ready1";
1349SET DEBUG_SYNC= "now SIGNAL t1_cont1";
1350SET DEBUG_SYNC= "now WAIT_FOR t1_ready2";
1351connection server_2;
1352SET DEBUG_SYNC= "now SIGNAL prep_cont";
1353SET DEBUG_SYNC= "now WAIT_FOR t3_ready";
1354SET DEBUG_SYNC= "now SIGNAL t2_cont1";
1355SET DEBUG_SYNC= "now WAIT_FOR t2_ready2";
1356SET DEBUG_SYNC= "now SIGNAL t1_cont2";
1357connection server_1;
1358connection server_2;
1359SELECT * FROM t2 WHERE a>=60 ORDER BY a;
1360a
136160
1362SELECT * FROM t1 WHERE a>=60 ORDER BY a;
1363a
136460
136561
1366SELECT * FROM t6 WHERE a>=60 ORDER BY a;
1367a
136862
1369SET DEBUG_SYNC="reset";
1370include/stop_slave.inc
1371SET GLOBAL debug_dbug=@old_dbug;
1372SET GLOBAL slave_parallel_threads=0;
1373SET GLOBAL slave_parallel_threads=10;
1374include/start_slave.inc
1375*** MDEV-7335: Potential parallel slave deadlock with specific binlog corruption ***
1376connection server_2;
1377include/stop_slave.inc
1378SET GLOBAL slave_parallel_threads=1;
1379SET @old_dbug= @@GLOBAL.debug_dbug;
1380SET GLOBAL debug_dbug="+d,slave_discard_xid_for_gtid_0_x_1000";
1381connection server_1;
1382INSERT INTO t2 VALUES (101);
1383INSERT INTO t2 VALUES (102);
1384INSERT INTO t2 VALUES (103);
1385INSERT INTO t2 VALUES (104);
1386INSERT INTO t2 VALUES (105);
1387SET gtid_seq_no=1000;
1388INSERT INTO t2 VALUES (106);
1389INSERT INTO t2 VALUES (107);
1390INSERT INTO t2 VALUES (108);
1391INSERT INTO t2 VALUES (109);
1392INSERT INTO t2 VALUES (110);
1393INSERT INTO t2 VALUES (111);
1394INSERT INTO t2 VALUES (112);
1395INSERT INTO t2 VALUES (113);
1396INSERT INTO t2 VALUES (114);
1397INSERT INTO t2 VALUES (115);
1398INSERT INTO t2 VALUES (116);
1399INSERT INTO t2 VALUES (117);
1400INSERT INTO t2 VALUES (118);
1401INSERT INTO t2 VALUES (119);
1402INSERT INTO t2 VALUES (120);
1403INSERT INTO t2 VALUES (121);
1404INSERT INTO t2 VALUES (122);
1405INSERT INTO t2 VALUES (123);
1406INSERT INTO t2 VALUES (124);
1407INSERT INTO t2 VALUES (125);
1408INSERT INTO t2 VALUES (126);
1409INSERT INTO t2 VALUES (127);
1410INSERT INTO t2 VALUES (128);
1411INSERT INTO t2 VALUES (129);
1412INSERT INTO t2 VALUES (130);
1413include/save_master_gtid.inc
1414connection server_2;
1415include/start_slave.inc
1416include/sync_with_master_gtid.inc
1417SELECT * FROM t2 WHERE a >= 100 ORDER BY a;
1418a
1419101
1420102
1421103
1422104
1423105
1424107
1425108
1426109
1427110
1428111
1429112
1430113
1431114
1432115
1433116
1434117
1435118
1436119
1437120
1438121
1439122
1440123
1441124
1442125
1443126
1444127
1445128
1446129
1447130
1448include/stop_slave.inc
1449SET GLOBAL debug_dbug=@old_dbug;
1450SET GLOBAL slave_parallel_threads=10;
1451include/start_slave.inc
1452*** MDEV-6676 - test syntax of @@slave_parallel_mode ***
1453connection server_2;
1454Parallel_Mode = 'conservative'
1455include/stop_slave.inc
1456SET GLOBAL slave_parallel_mode='aggressive';
1457Parallel_Mode = 'aggressive'
1458SET GLOBAL slave_parallel_mode='conservative';
1459Parallel_Mode = 'conservative'
1460*** MDEV-6676 - test that empty parallel_mode does not replicate in parallel ***
1461connection server_1;
1462INSERT INTO t2 VALUES (1040);
1463include/save_master_gtid.inc
1464connection server_2;
1465SET GLOBAL slave_parallel_mode='none';
1466SET @old_dbug= @@GLOBAL.debug_dbug;
1467SET GLOBAL debug_dbug="+d,slave_crash_if_parallel_apply";
1468include/start_slave.inc
1469include/sync_with_master_gtid.inc
1470SELECT * FROM t2 WHERE a >= 1040 ORDER BY a;
1471a
14721040
1473include/stop_slave.inc
1474SET GLOBAL debug_dbug=@old_dbug;
1475*** MDEV-6676 - test disabling domain-based parallel replication ***
1476connection server_1;
1477SET gtid_domain_id = 1;
1478INSERT INTO t2 VALUES (1041);
1479INSERT INTO t2 VALUES (1042);
1480INSERT INTO t2 VALUES (1043);
1481INSERT INTO t2 VALUES (1044);
1482INSERT INTO t2 VALUES (1045);
1483INSERT INTO t2 VALUES (1046);
1484DELETE FROM t2 WHERE a >= 1041;
1485SET gtid_domain_id = 2;
1486INSERT INTO t2 VALUES (1041);
1487INSERT INTO t2 VALUES (1042);
1488INSERT INTO t2 VALUES (1043);
1489INSERT INTO t2 VALUES (1044);
1490INSERT INTO t2 VALUES (1045);
1491INSERT INTO t2 VALUES (1046);
1492SET gtid_domain_id = 0;
1493include/save_master_gtid.inc
1494connection server_2;
1495SET GLOBAL slave_parallel_mode=minimal;
1496include/start_slave.inc
1497include/sync_with_master_gtid.inc
1498SELECT * FROM t2 WHERE a >= 1040 ORDER BY a;
1499a
15001040
15011041
15021042
15031043
15041044
15051045
15061046
1507*** MDEV-7888: ANALYZE TABLE does wakeup_subsequent_commits(), causing wrong binlog order and parallel replication hang ***
1508connection server_2;
1509include/stop_slave.inc
1510SET GLOBAL slave_parallel_mode='conservative';
1511SET GLOBAL slave_parallel_threads=10;
1512SET @old_dbug= @@GLOBAL.debug_dbug;
1513SET GLOBAL debug_dbug= '+d,inject_analyze_table_sleep';
1514connection server_1;
1515SET @old_dbug_slave= @@SESSION.debug_dbug;
1516SET SESSION debug_dbug="+d,binlog_force_commit_id";
1517SET @commit_id= 10000;
1518ANALYZE TABLE t2;
1519Table	Op	Msg_type	Msg_text
1520test.t2	analyze	status	Engine-independent statistics collected
1521test.t2	analyze	status	OK
1522INSERT INTO t3 VALUES (120, 0);
1523SET @commit_id= 10001;
1524INSERT INTO t3 VALUES (121, 0);
1525SET SESSION debug_dbug=@old_dbug_slave;
1526SELECT * FROM t3 WHERE a >= 120 ORDER BY a;
1527a	b
1528120	0
1529121	0
1530include/save_master_gtid.inc
1531connection server_2;
1532include/start_slave.inc
1533include/sync_with_master_gtid.inc
1534SELECT * FROM t3 WHERE a >= 120 ORDER BY a;
1535a	b
1536120	0
1537121	0
1538include/stop_slave.inc
1539SET GLOBAL debug_dbug= @old_dbug;
1540include/start_slave.inc
1541*** MDEV-7929: record_gtid() for non-transactional event group calls wakeup_subsequent_commits() too early, causing slave hang. ***
1542connection server_2;
1543include/stop_slave.inc
1544SET @old_dbug= @@GLOBAL.debug_dbug;
1545SET GLOBAL debug_dbug= '+d,inject_record_gtid_serverid_100_sleep';
1546connection server_1;
1547SET @old_dbug_slave= @@SESSION.debug_dbug;
1548SET SESSION debug_dbug="+d,binlog_force_commit_id";
1549SET @old_server_id= @@SESSION.server_id;
1550SET SESSION server_id= 100;
1551SET @commit_id= 10010;
1552ALTER TABLE t1 COMMENT "Hulubulu!";
1553SET SESSION server_id= @old_server_id;
1554INSERT INTO t3 VALUES (130, 0);
1555SET @commit_id= 10011;
1556INSERT INTO t3 VALUES (131, 0);
1557SET SESSION debug_dbug=@old_dbug_slave;
1558SELECT * FROM t3 WHERE a >= 130 ORDER BY a;
1559a	b
1560130	0
1561131	0
1562include/save_master_gtid.inc
1563connection server_2;
1564include/start_slave.inc
1565include/sync_with_master_gtid.inc
1566SELECT * FROM t3 WHERE a >= 130 ORDER BY a;
1567a	b
1568130	0
1569131	0
1570include/stop_slave.inc
1571SET GLOBAL debug_dbug= @old_dbug;
1572include/start_slave.inc
1573*** MDEV-8031: Parallel replication stops on "connection killed" error (probably incorrectly handled deadlock kill) ***
1574connection server_1;
1575INSERT INTO t3 VALUES (201,0), (202,0);
1576include/save_master_gtid.inc
1577connection server_2;
1578include/sync_with_master_gtid.inc
1579include/stop_slave.inc
1580SET @old_dbug= @@GLOBAL.debug_dbug;
1581SET GLOBAL debug_dbug= '+d,inject_mdev8031';
1582connection server_1;
1583SET @old_dbug_slave= @@SESSION.debug_dbug;
1584SET SESSION debug_dbug="+d,binlog_force_commit_id";
1585SET @commit_id= 10200;
1586INSERT INTO t3 VALUES (203, 1);
1587INSERT INTO t3 VALUES (204, 1);
1588INSERT INTO t3 VALUES (205, 1);
1589UPDATE t3 SET b=b+1 WHERE a=201;
1590UPDATE t3 SET b=b+1 WHERE a=201;
1591UPDATE t3 SET b=b+1 WHERE a=201;
1592UPDATE t3 SET b=b+1 WHERE a=202;
1593UPDATE t3 SET b=b+1 WHERE a=202;
1594UPDATE t3 SET b=b+1 WHERE a=202;
1595UPDATE t3 SET b=b+1 WHERE a=202;
1596UPDATE t3 SET b=b+1 WHERE a=203;
1597UPDATE t3 SET b=b+1 WHERE a=203;
1598UPDATE t3 SET b=b+1 WHERE a=204;
1599UPDATE t3 SET b=b+1 WHERE a=204;
1600UPDATE t3 SET b=b+1 WHERE a=204;
1601UPDATE t3 SET b=b+1 WHERE a=203;
1602UPDATE t3 SET b=b+1 WHERE a=205;
1603UPDATE t3 SET b=b+1 WHERE a=205;
1604SET SESSION debug_dbug=@old_dbug_slave;
1605SELECT * FROM t3 WHERE a>=200 ORDER BY a;
1606a	b
1607201	3
1608202	4
1609203	4
1610204	4
1611205	3
1612include/save_master_gtid.inc
1613connection server_2;
1614include/start_slave.inc
1615include/sync_with_master_gtid.inc
1616SELECT * FROM t3 WHERE a>=200 ORDER BY a;
1617a	b
1618201	3
1619202	4
1620203	4
1621204	4
1622205	3
1623include/stop_slave.inc
1624SET GLOBAL debug_dbug= @old_dbug;
1625include/start_slave.inc
1626*** Check getting deadlock killed inside open_binlog() during retry. ***
1627connection server_2;
1628include/stop_slave.inc
1629SET @old_dbug= @@GLOBAL.debug_dbug;
1630SET GLOBAL debug_dbug= '+d,inject_retry_event_group_open_binlog_kill';
1631SET @old_max= @@GLOBAL.max_relay_log_size;
1632SET GLOBAL max_relay_log_size= 4096;
1633connection server_1;
1634SET @old_dbug_slave= @@SESSION.debug_dbug;
1635SET SESSION debug_dbug="+d,binlog_force_commit_id";
1636SET @commit_id= 10210;
1637Omit long queries that cause relaylog rotations and transaction retries...
1638SET SESSION debug_dbug=@old_dbug_slave;
1639SELECT * FROM t3 WHERE a>=200 ORDER BY a;
1640a	b
1641201	6
1642202	8
1643203	7
1644204	7
1645205	5
1646include/save_master_gtid.inc
1647connection server_2;
1648include/start_slave.inc
1649include/sync_with_master_gtid.inc
1650SELECT * FROM t3 WHERE a>=200 ORDER BY a;
1651a	b
1652201	6
1653202	8
1654203	7
1655204	7
1656205	5
1657include/stop_slave.inc
1658SET GLOBAL debug_dbug= @old_dbug;
1659SET GLOBAL max_relay_log_size= @old_max;
1660include/start_slave.inc
1661*** MDEV-8725: Assertion on ROLLBACK statement in the binary log ***
1662connection server_1;
1663BEGIN;
1664INSERT INTO t2 VALUES (2000);
1665INSERT INTO t1 VALUES (2000);
1666INSERT INTO t2 VALUES (2001);
1667ROLLBACK;
1668SELECT * FROM t1 WHERE a>=2000 ORDER BY a;
1669a
16702000
1671SELECT * FROM t2 WHERE a>=2000 ORDER BY a;
1672a
1673include/save_master_gtid.inc
1674connection server_2;
1675include/sync_with_master_gtid.inc
1676SELECT * FROM t1 WHERE a>=2000 ORDER BY a;
1677a
16782000
1679SELECT * FROM t2 WHERE a>=2000 ORDER BY a;
1680a
1681connection server_2;
1682include/stop_slave.inc
1683SET GLOBAL slave_parallel_threads=@old_parallel_threads;
1684include/start_slave.inc
1685SET DEBUG_SYNC= 'RESET';
1686connection server_1;
1687DROP function foo;
1688DROP TABLE t1,t2,t3,t4,t5,t6;
1689SET DEBUG_SYNC= 'RESET';
1690include/rpl_end.inc
1691