Debian Codegraph @

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

raw
1 --source include/have_innodb.inc
2 --source include/have_debug.inc
3 --source include/have_binlog_format_statement.inc
4 # Valgrind does not work well with test that crashes the server
5 --source include/not_valgrind.inc
6 --let $rpl_topology=1->2
7 --source include/rpl_init.inc
8
9 --echo *** MDEV-6321: close_temporary_tables() in format description event not serialised correctly ***
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=5;
15 --source include/start_slave.inc
16
17 --connection server_1
18 CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(100) CHARACTER SET utf8);
19 --save_master_pos
20
21 --connection server_2
22 --sync_with_master
23 --source include/stop_slave.inc
24
25
26 --connection server_1
27 SET gtid_domain_id= 1;
28 INSERT INTO t1 VALUES (1, 0);
29
30 CREATE TEMPORARY TABLE t2 (a int);
31
32 --connection default
33 SET gtid_domain_id= 2;
34 CREATE TEMPORARY TABLE t3 (a INT PRIMARY KEY);
35 CREATE TEMPORARY TABLE t4 (a int);
36 INSERT INTO t3 VALUES (100);
37 INSERT INTO t4 SELECT a+1 FROM t3;
38
39 --connection server_1
40 INSERT INTO t2 VALUES (2), (4), (6), (8), (10), (12), (14), (16), (18), (20);
41 INSERT INTO t2 VALUES (3), (6), (9), (12), (15), (18);
42 INSERT INTO t2 VALUES (4), (8), (12), (16), (20);
43
44 --connection default
45 INSERT INTO t3 SELECT a+2 FROM t4;
46 INSERT INTO t4 SELECT a+4 FROM t3;
47
48 --connection server_1
49 INSERT INTO t2 VALUES (5), (10), (15), (20);
50 INSERT INTO t2 VALUES (6), (12), (18);
51 INSERT INTO t2 VALUES (7), (14);
52 INSERT INTO t2 VALUES (8), (16);
53 INSERT INTO t2 VALUES (9), (18);
54 INSERT INTO t2 VALUES (10), (20);
55
56 --connection default
57 INSERT INTO t3 SELECT a+8 FROM t4;
58 INSERT INTO t4 SELECT a+16 FROM t3;
59
60 --connection server_1
61 INSERT INTO t2 VALUES (11);
62 INSERT INTO t2 VALUES (12);
63 INSERT INTO t2 VALUES (13);
64
65 --connection default
66 INSERT INTO t3 SELECT a+32 FROM t4;
67
68 --connection server_1
69 INSERT INTO t2 VALUES (14);
70 INSERT INTO t2 VALUES (15);
71 INSERT INTO t2 VALUES (16);
72
73 --connection default
74 INSERT INTO t4 SELECT a+64 FROM t3;
75
76 --connection server_1
77 INSERT INTO t2 VALUES (17);
78 INSERT INTO t2 VALUES (18);
79 INSERT INTO t2 VALUES (19);
80
81 --connection default
82 INSERT INTO t3 SELECT a+128 FROM t4;
83
84 --connection server_1
85 INSERT INTO t2 VALUES (20);
86
87 --connection default
88 INSERT INTO t1 SELECT a, a MOD 7 FROM t3;
89 INSERT INTO t1 SELECT a, a MOD 7 FROM t4;
90
91 --connection server_1
92 INSERT INTO t1 SELECT a, COUNT(*) FROM t2 GROUP BY a;
93
94 # Crash the master server, so that temporary tables are implicitly dropped.
95 --write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
96 wait
97 EOF
98
99 FLUSH TABLES;
100 SET SESSION debug_dbug="+d,crash_dispatch_command_before";
101 --error 2006,2013
102 SELECT 1;
103
104 --source include/wait_until_disconnected.inc
105 --connection default
106 --source include/wait_until_disconnected.inc
107
108 --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
109 restart
110 EOF
111
112 --connection default
113 --enable_reconnect
114 --source include/wait_until_connected_again.inc
115
116 --connection server_1
117 --enable_reconnect
118 --source include/wait_until_connected_again.inc
119
120 INSERT INTO t1 VALUES (0, 1);
121 --save_master_pos
122
123 --connection server_2
124 # Start the slave replicating the events.
125 # The bug was that the format description event written after the crash could
126 # be fetched ahead of the execution of the temporary table events and executed
127 # out-of-band. This would cause drop of all temporary tables and thus failure
128 # for execution of remaining events.
129
130 --source include/start_slave.inc
131 --sync_with_master
132
133 SELECT * FROM t1 WHERE a <= 20 ORDER BY a;
134 SELECT COUNT(*) FROM t1 WHERE a BETWEEN 100+0 AND 100+256;
135 SHOW STATUS LIKE 'Slave_open_temp_tables';
136
137
138 --echo *** Test that if master logged partial event group before crash, we finish that group correctly before executing format description event ***
139
140 --source include/stop_slave.inc
141
142 --connection server_1
143 CALL mtr.add_suppression("Statement accesses nontransactional table as well as transactional or temporary table, and writes to any of them");
144 SET gtid_domain_id= 1;
145 DELETE FROM t1;
146 ALTER TABLE t1 ENGINE=InnoDB;
147 CREATE TEMPORARY TABLE t2 (a INT PRIMARY KEY);
148 INSERT INTO t2 VALUES (1);
149 INSERT INTO t2 VALUES (2);
150
151 --connection default
152 SET gtid_domain_id= 2;
153 CREATE TEMPORARY TABLE t3 (a INT PRIMARY KEY);
154 INSERT INTO t3 VALUES (10);
155 INSERT INTO t3 VALUES (20);
156
157 --connection server_1
158 INSERT INTO t1 SELECT a, 'server_1' FROM t2;
159
160 --connection default
161 INSERT INTO t1 SELECT a, 'default' FROM t3;
162
163 --connection server_1
164 INSERT INTO t1 SELECT a+2, '+server_1' FROM t2;
165
166 # Crash the master server in the middle of writing an event group.
167 --write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
168 wait
169 EOF
170
171 FLUSH TABLES;
172 SET SESSION debug_dbug="+d,crash_before_writing_xid";
173 --error 2006,2013
174 INSERT INTO t1 SELECT a+4, '++server_1' FROM t2;
175
176 --source include/wait_until_disconnected.inc
177 --connection default
178 --source include/wait_until_disconnected.inc
179
180 --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
181 restart
182 EOF
183
184 --connection default
185 --enable_reconnect
186 --source include/wait_until_connected_again.inc
187
188 --connection server_1
189 --enable_reconnect
190 --source include/wait_until_connected_again.inc
191
192 INSERT INTO t1 VALUES (0, 1);
193 #--save_master_pos
194 --source include/save_master_gtid.inc
195
196 --connection server_2
197 # Start the slave replicating the events.
198 # The main thing to test here is that the slave will know that it
199 # needs to abort the partially received event group, so that the
200 # execution of format_description event will not wait infinitely
201 # for a commit of the incomplete group that never happens.
202
203 # Apart from the suppression, MDEV-27697 refinement to the original test needs
204 # an allowance to one time accept malformed event group.
205 set @@sql_log_bin=0;
206 call mtr.add_suppression("Unexpected break of being relay-logged GTID 1-1-32 event group by the current GTID event 0-1-4");
207 set @@sql_log_bin=1;
208 set @@global.debug_dbug="+d,slave_discard_xid_for_gtid_0_x_1000";
209 --source include/start_slave.inc
210 #--sync_with_master
211 --source include/sync_with_master_gtid.inc
212 set @@global.debug_dbug="";
213
214 SELECT * FROM t1 ORDER BY a;
215 SHOW STATUS LIKE 'Slave_open_temp_tables';
216
217 --connection server_1
218 # This FLUSH can be removed once MDEV-6608 is fixed.
219 FLUSH LOGS;
220
221
222 --echo *** MDEV-7936: Assertion `!table || table->in_use == _current_thd()' failed on parallel replication in optimistic mode ***
223
224 --connection server_1
225 CREATE TEMPORARY TABLE t4 (a INT PRIMARY KEY) ENGINE=InnoDB;
226 SET @old_dbug= @@SESSION.debug_dbug;
227 SET SESSION debug_dbug="+d,binlog_force_commit_id";
228 SET @commit_id= 10000;
229 INSERT INTO t4 VALUES (30);
230 INSERT INTO t4 VALUES (31);
231 SET SESSION debug_dbug= @old_dbug;
232 INSERT INTO t1 SELECT a, "conservative" FROM t4;
233 DROP TEMPORARY TABLE t4;
234 SELECT * FROM t1 WHERE a >= 30 ORDER BY a;
235 --source include/save_master_gtid.inc
236
237 --connection server_2
238 --source include/sync_with_master_gtid.inc
239
240 SELECT * FROM t1 WHERE a >= 30 ORDER BY a;
241
242 --source include/stop_slave.inc
243 SET @old_mode= @@GLOBAL.slave_parallel_mode;
244 SET GLOBAL slave_parallel_mode=optimistic;
245
246 --connection server_1
247 CREATE TEMPORARY TABLE t4 (a INT PRIMARY KEY) ENGINE=InnoDB;
248 INSERT INTO t4 VALUES (32);
249 INSERT INTO t4 VALUES (33);
250 INSERT INTO t1 SELECT a, "optimistic" FROM t4;
251 DROP TEMPORARY TABLE t4;
252
253 SELECT * FROM t1 WHERE a >= 30 ORDER BY a;
254 --source include/save_master_gtid.inc
255
256 --connection server_2
257 --source include/start_slave.inc
258 --source include/sync_with_master_gtid.inc
259
260 SELECT * FROM t1 WHERE a >= 30 ORDER BY a;
261
262 --source include/stop_slave.inc
263 SET GLOBAL slave_parallel_mode=@old_mode;
264 --source include/start_slave.inc
265
266
267 --echo *** MDEV33426: Memory allocation accounting incorrect for replicated temptable
268 --connection server_1
269 CREATE TEMPORARY TABLE t5 (a int) ENGINE=Aria;
270 CREATE TEMPORARY TABLE t6 (a int) ENGINE=Heap;
271 INSERT INTO t5 VALUES (1);
272 INSERT INTO t6 VALUES (2);
273 --save_master_pos
274
275 --connection server_2
276 --sync_with_master
277 --source include/stop_slave.inc
278
279 --connection server_1
280 INSERT INTO t1 SELECT a+40, 5 FROM t5;
281 INSERT INTO t1 SELECT a+40, 6 FROM t6;
282 DROP TABLE t5, t6;
283
284 --save_master_pos
285
286 --connection server_2
287 --source include/start_slave.inc
288 --sync_with_master
289 SELECT * FROM t1 WHERE a>=40 ORDER BY a;
290
291 # Clean up.
292
293 --connection server_2
294 --source include/stop_slave.inc
295 SET GLOBAL slave_parallel_threads=@old_parallel_threads;
296 --source include/start_slave.inc
297
298 --connection server_1
299 DROP TABLE t1;
300
301 --source include/rpl_end.inc