Debian Codegraph @

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

raw
1 # Test is independent of slave_parallel_mode
2 --echo *** Test two transactions in different domains committed in opposite order on slave but in a single group commit. ***
3
4 --source include/have_innodb.inc
5 --source include/have_debug.inc
6 --source include/have_debug_sync.inc
7 --source include/master-slave.inc
8
9 # Test various aspects of parallel replication.
10
11 --connection server_2
12 SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
13 --source include/stop_slave.inc
14 SET GLOBAL slave_parallel_threads=10;
15 CHANGE MASTER TO master_use_gtid=slave_pos;
16 --source include/start_slave.inc
17
18 --connection server_1
19 ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
20 CREATE TABLE t1 (a int PRIMARY KEY) ENGINE=MyISAM;
21 CREATE TABLE t2 (a int PRIMARY KEY) ENGINE=InnoDB;
22 INSERT INTO t1 VALUES (1);
23 INSERT INTO t2 VALUES (1);
24 --save_master_pos
25
26 --connection server_2
27 --sync_with_master
28 --source include/stop_slave.inc
29
30 --connection server_1
31 # Use a stored function to inject a debug_sync into the appropriate THD.
32 # The function does nothing on the master, and on the slave it injects the
33 # desired debug_sync action(s).
34 SET sql_log_bin=0;
35 --delimiter ||
36 CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
37 RETURNS INT DETERMINISTIC
38 BEGIN
39 RETURN x;
40 END
41 ||
42 --delimiter ;
43 SET sql_log_bin=1;
44
45 SET @old_format= @@SESSION.binlog_format;
46 SET binlog_format='statement';
47 SET gtid_domain_id=1;
48 INSERT INTO t2 VALUES (foo(10,
49 'commit_before_enqueue SIGNAL ready1 WAIT_FOR cont1',
50 'commit_after_release_LOCK_prepare_ordered SIGNAL ready2'));
51
52 --connection server_2
53 FLUSH LOGS;
54 --source include/wait_for_binlog_checkpoint.inc
55 SET sql_log_bin=0;
56 --delimiter ||
57 CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
58 RETURNS INT DETERMINISTIC
59 BEGIN
60 IF d1 != '' THEN
61 SET debug_sync = d1;
62 END IF;
63 IF d2 != '' THEN
64 SET debug_sync = d2;
65 END IF;
66 RETURN x;
67 END
68 ||
69 --delimiter ;
70 SET sql_log_bin=1;
71 SET @old_format=@@GLOBAL.binlog_format;
72 SET GLOBAL binlog_format=statement;
73 # We need to restart all parallel threads for the new global setting to
74 # be copied to the session-level values.
75 SET GLOBAL slave_parallel_threads=0;
76 SET GLOBAL slave_parallel_threads=10;
77 --source include/start_slave.inc
78
79 # First make sure the first insert is ready to commit, but not queued yet.
80 SET debug_sync='now WAIT_FOR ready1';
81
82 --connection server_1
83 SET gtid_domain_id=2;
84 INSERT INTO t2 VALUES (foo(11,
85 'commit_before_enqueue SIGNAL ready3 WAIT_FOR cont3',
86 'commit_after_release_LOCK_prepare_ordered SIGNAL ready4 WAIT_FOR cont4'));
87 SET gtid_domain_id=0;
88 SELECT * FROM t2 WHERE a >= 10 ORDER BY a;
89
90 --connection server_2
91 # Now wait for the second insert to queue itself as the leader, and then
92 # wait for more commits to queue up.
93 SET debug_sync='now WAIT_FOR ready3';
94 SET debug_sync='now SIGNAL cont3';
95 SET debug_sync='now WAIT_FOR ready4';
96 # Now allow the first insert to queue up to participate in group commit.
97 SET debug_sync='now SIGNAL cont1';
98 SET debug_sync='now WAIT_FOR ready2';
99 # Finally allow the second insert to proceed and do the group commit.
100 SET debug_sync='now SIGNAL cont4';
101
102 --let $wait_condition= SELECT COUNT(*) = 2 FROM t2 WHERE a >= 10
103 --source include/wait_condition.inc
104 SELECT * FROM t2 WHERE a >= 10 ORDER BY a;
105 # The two INSERT transactions should have been committed in opposite order,
106 # but in the same group commit (seen by precense of cid=# in the SHOW
107 # BINLOG output).
108 --let $binlog_file= slave-bin.000002
109 --source include/show_binlog_events.inc
110 FLUSH LOGS;
111 --source include/wait_for_binlog_checkpoint.inc
112
113
114 # Clean up.
115 --connection server_2
116 --source include/stop_slave.inc
117 SET GLOBAL slave_parallel_threads=@old_parallel_threads;
118 --source include/start_slave.inc
119 SET DEBUG_SYNC= 'RESET';
120 SET GLOBAL binlog_format=@old_format;
121
122 --connection server_1
123 DROP function foo;
124 DROP TABLE t1,t2;
125 SET DEBUG_SYNC= 'RESET';
126 SET GLOBAL binlog_format=@old_format;
127
128 --source include/rpl_end.inc