Debian Codegraph @

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

raw
1 --echo *** MDEV-6775: Wrong binlog order in parallel replication ***
2
3 # A bit tricky bug to reproduce. On the master, we binlog in statement-mode
4 # two transactions, an UPDATE followed by a DELETE. On the slave, we replicate
5 # with binlog-mode set to ROW, which means the DELETE, which modifies no rows,
6 # is not binlogged. Then we inject a wait in the group commit code on the
7 # slave, shortly before the actual commit of the UPDATE. The bug was that the
8 # DELETE could wake up from wait_for_prior_commit() before the commit of the
9 # UPDATE. So the test could see the slave position updated to after DELETE,
10 # while the UPDATE was still not visible.
11
12 --source include/have_innodb.inc
13 --source include/have_debug.inc
14 --source include/have_debug_sync.inc
15 --source include/master-slave.inc
16
17 --connection server_2
18 SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
19 --source include/stop_slave.inc
20 SET GLOBAL slave_parallel_threads=10;
21 CHANGE MASTER TO master_use_gtid=slave_pos;
22 --source include/start_slave.inc
23
24 --connection server_1
25 ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
26 CREATE TABLE t4 (a INT PRIMARY KEY, b INT, KEY b_idx(b)) ENGINE=InnoDB;
27 INSERT INTO t4 VALUES (1,NULL), (3,NULL), (4,4), (5, NULL), (6, 6);
28 --connect (con1,127.0.0.1,root,,test,$SERVER_MYPORT_1,)
29 --connect (con2,127.0.0.1,root,,test,$SERVER_MYPORT_1,)
30 --source include/save_master_gtid.inc
31
32 --connection server_2
33 --source include/sync_with_master_gtid.inc
34 --source include/stop_slave.inc
35 SET @old_dbug= @@GLOBAL.debug_dbug;
36 SET GLOBAL debug_dbug="+d,inject_binlog_commit_before_get_LOCK_log";
37 SET @old_format=@@GLOBAL.binlog_format;
38 SET GLOBAL binlog_format=ROW;
39 # Re-spawn the worker threads to be sure they pick up the new binlog format
40 SET GLOBAL slave_parallel_threads=0;
41 SET GLOBAL slave_parallel_threads=10;
42
43 --connection con1
44 SET @old_format= @@binlog_format;
45 SET binlog_format= statement;
46 SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1';
47 send UPDATE t4 SET b=NULL WHERE a=6;
48 --connection server_1
49 SET debug_sync='now WAIT_FOR master_queued1';
50
51 --connection con2
52 SET @old_format= @@binlog_format;
53 SET binlog_format= statement;
54 SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2';
55 send DELETE FROM t4 WHERE b <= 3;
56
57 --connection server_1
58 SET debug_sync='now WAIT_FOR master_queued2';
59 SET debug_sync='now SIGNAL master_cont1';
60
61 --connection con1
62 REAP;
63 SET binlog_format= @old_format;
64 --connection con2
65 REAP;
66 SET binlog_format= @old_format;
67 SET debug_sync='RESET';
68 --save_master_pos
69 SELECT * FROM t4 ORDER BY a;
70
71 --connection server_2
72 --source include/start_slave.inc
73 SET debug_sync= 'now WAIT_FOR waiting';
74 --sync_with_master
75 SELECT * FROM t4 ORDER BY a;
76 SET debug_sync= 'now SIGNAL cont';
77
78 # Re-spawn the worker threads to remove any DBUG injections or DEBUG_SYNC.
79 --source include/stop_slave.inc
80 SET GLOBAL debug_dbug=@old_dbug;
81 SET GLOBAL binlog_format= @old_format;
82 SET GLOBAL slave_parallel_threads=@old_parallel_threads;
83 --source include/start_slave.inc
84 SET DEBUG_SYNC= 'RESET';
85
86 --connection server_1
87 DROP TABLE t4;
88 SET DEBUG_SYNC= 'RESET';
89 --disconnect con1
90 --disconnect con2
91 --source include/rpl_end.inc