Debian Codegraph @

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

raw
1 --source include/have_innodb.inc
2 --source include/have_debug.inc
3 --source include/master-slave.inc
4
5 --echo *** Test that we check against incorrect table definition for mysql.gtid_slave_pos ***
6 --connection master
7 CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
8 call mtr.add_suppression("Incorrect definition of table mysql.gtid_slave_pos:.*");
9 --sync_slave_with_master
10
11 --connection slave
12 --source include/stop_slave.inc
13 ALTER TABLE mysql.gtid_slave_pos CHANGE seq_no seq_no VARCHAR(20);
14 START SLAVE;
15
16 --connection master
17 INSERT INTO t1 VALUES (1);
18
19 --connection slave
20 CALL mtr.add_suppression("Slave: Failed to open mysql.gtid_slave_pos");
21 --let $slave_sql_errno=1944
22 --source include/wait_for_slave_sql_error.inc
23 --let $rpl_only_running_threads= 1
24 --source include/stop_slave.inc
25 ALTER TABLE mysql.gtid_slave_pos CHANGE seq_no seq_no BIGINT UNSIGNED NOT NULL;
26 ALTER TABLE mysql.gtid_slave_pos DROP PRIMARY KEY;
27 ALTER TABLE mysql.gtid_slave_pos ADD PRIMARY KEY (sub_id, domain_id);
28 START SLAVE;
29 --let $slave_sql_errno=1944
30 --source include/wait_for_slave_sql_error.inc
31
32 --source include/stop_slave.inc
33 ALTER TABLE mysql.gtid_slave_pos DROP PRIMARY KEY;
34 START SLAVE;
35 --let $slave_sql_errno=1944
36 --source include/wait_for_slave_sql_error.inc
37
38 --source include/stop_slave.inc
39 ALTER TABLE mysql.gtid_slave_pos ADD PRIMARY KEY (sub_id);
40 START SLAVE;
41 --let $slave_sql_errno=1944
42 --source include/wait_for_slave_sql_error.inc
43
44 --source include/stop_slave.inc
45 ALTER TABLE mysql.gtid_slave_pos DROP PRIMARY KEY;
46 ALTER TABLE mysql.gtid_slave_pos ADD PRIMARY KEY (domain_id, sub_id);
47 --source include/start_slave.inc
48
49 --connection master
50 --sync_slave_with_master
51
52 --connection slave
53 SELECT * FROM t1;
54
55
56 --echo *** Test that setting @@gtid_domain_id or @@gtid_seq_no is not allowed inside a transaction. ***
57 BEGIN;
58 INSERT INTO t1 VALUES (100);
59 --error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_GTID_DOMAIN_ID_SEQ_NO
60 SET SESSION gtid_domain_id= 100;
61 --error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_GTID_DOMAIN_ID_SEQ_NO
62 SET SESSION gtid_seq_no= 100;
63 SET @old_domain= @@GLOBAL.gtid_domain_id;
64 SET GLOBAL gtid_domain_id= 100;
65 SELECT @@SESSION.gtid_domain_id;
66 SET GLOBAL gtid_domain_id= @old_domain;
67 INSERT INTO t1 VALUES (101);
68 SELECT * FROM t1 ORDER BY a;
69 ROLLBACK;
70 SELECT * FROM t1 ORDER BY a;
71
72 # MDEV-34049: Parallel access to temptable in different domain_id in parallel replication
73 #
74 # Temporary tables must be prevented from being accessed from multiple threads
75 # at the same time in parallel replication. Withon one domain_id, this is done
76 # by running wait_for_prior_commit() before accessing a temporary table. To
77 # prevent the same temporary table from being accessed in parallel from two
78 # domains in out-of-order parallel replication, an error must be raised on
79 # attempt to change the gtid_domain_id while temporary tables are in use in
80 # a session and binlogged. In row-based binlogging, temporary tables are not
81 # binlogged, so gtid_domain_id can be freely changed.
82 SET @old_mode= @@SESSION.binlog_format;
83 SET SESSION binlog_format= row;
84 SET SESSION gtid_domain_id= 200;
85 CREATE TEMPORARY TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
86 SET SESSION gtid_domain_id= 0;
87 BEGIN;
88 INSERT INTO t2 VALUES (200);
89 INSERT INTO t1 SELECT * FROM t2;
90 COMMIT;
91 SET SESSION gtid_domain_id= 201;
92 SET SESSION gtid_domain_id= 0;
93 DELETE FROM t1 WHERE a=200;
94 SET SESSION gtid_domain_id= 202;
95 DROP TEMPORARY TABLE t2;
96
97 SET SESSION binlog_format= mixed;
98 SET SESSION gtid_domain_id= 0;
99 CREATE TEMPORARY TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
100 INSERT INTO t2 VALUES (1);
101 SET SESSION gtid_domain_id= 0;
102 --error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_GTID_DOMAIN_ID_SEQ_NO
103 SET SESSION gtid_domain_id= 204;
104 SET SESSION binlog_format=statement;
105 INSERT INTO t2 VALUES (2);
106 --error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_GTID_DOMAIN_ID_SEQ_NO
107 SET SESSION gtid_domain_id= 205;
108 DROP TEMPORARY TABLE t2;
109 SET SESSION gtid_domain_id= @old_domain;
110 SET SESSION binlog_format= @old_mode;
111
112
113 --echo *** Test requesting an explicit GTID position that conflicts with newer GTIDs of our own in the binlog. ***
114 --connection slave
115 --source include/stop_slave.inc
116
117 --connection master
118 RESET MASTER;
119 # This insert will be GTID 0-1-1
120 INSERT INTO t1 VALUES (2);
121 # And this will be GTID 0-1-2
122 INSERT INTO t1 VALUES (4);
123 --source include/save_master_gtid.inc
124
125 --connection slave
126 SET sql_log_bin = 0;
127 INSERT INTO t1 VALUES (2);
128 SET sql_log_bin = 1;
129 INSERT INTO t1 VALUES (3);
130
131 CHANGE MASTER TO master_use_gtid=current_pos;
132 # Most not change @@GLOBAL.gtid_slave_pos in the middle of a transaction.
133 BEGIN;
134 --error ER_CANT_DO_THIS_DURING_AN_TRANSACTION
135 SET GLOBAL gtid_slave_pos = "100-100-100";
136 INSERT INTO t1 VALUES (100);
137 --error ER_CANT_DO_THIS_DURING_AN_TRANSACTION
138 SET GLOBAL gtid_slave_pos = "100-100-100";
139 ROLLBACK;
140
141 # In gtid non-strict mode, we get warnings for setting @@gtid_slave_pos back
142 # to earlier than what is in the binlog. In strict mode, we get an error.
143 SET GLOBAL gtid_strict_mode= 1;
144 --error ER_MASTER_GTID_POS_CONFLICTS_WITH_BINLOG
145 SET GLOBAL gtid_slave_pos = "0-1-1";
146 --error ER_MASTER_GTID_POS_MISSING_DOMAIN
147 SET GLOBAL gtid_slave_pos = "";
148 SET GLOBAL gtid_strict_mode= 0;
149 SET GLOBAL gtid_slave_pos = "0-1-1";
150 SET GLOBAL gtid_slave_pos = "";
151 RESET MASTER;
152 SET GLOBAL gtid_slave_pos = "0-1-1";
153
154 START SLAVE;
155 --source include/sync_with_master_gtid.inc
156 SELECT * FROM t1 ORDER BY a;
157
158 --echo *** MDEV-4688: Empty value of @@GLOBAL.gtid_slave_pos ***
159 # The problem was that record_gtid() deleted too much of the in-memory state,
160 # leaving the state empty until after commit when we add the newly committed
161 # GTID. Test this by forcing an error after the delete of the old data but
162 # before the add of new data.
163
164 --source include/stop_slave.inc
165
166 --connection master
167 # This will be GTID 0-1-3
168 INSERT INTO t1 VALUES (5);
169 --source include/save_master_gtid.inc
170
171 --connection slave
172 SET @old_dbug= @@GLOBAL.debug_dbug;
173 SET GLOBAL debug_dbug="+d,dummy_disable_default_dbug_output";
174 SET GLOBAL debug_dbug="+d,gtid_fail_after_record_gtid";
175 SET sql_log_bin=0;
176 CALL mtr.add_suppression('Got error 131 "Command not supported by the engine" during COMMIT');
177 SET sql_log_bin=1;
178 START SLAVE;
179 --let $slave_sql_errno= 1180
180 --source include/wait_for_slave_sql_error.inc
181 # The bug was that @@GLOBAL.gtid_slave_pos was empty here.
182 SELECT @@GLOBAL.gtid_slave_pos;
183 SELECT * FROM t1 ORDER BY a;
184 SET GLOBAL debug_dbug= @old_dbug;
185 START SLAVE SQL_THREAD;
186 --source include/sync_with_master_gtid.inc
187 SELECT * FROM t1 ORDER BY a;
188
189
190 --echo *** Test slave requesting a GTID that is not present in the master's binlog ***
191 --source include/stop_slave.inc
192 SET GLOBAL gtid_slave_pos = "0-1-4";
193 START SLAVE;
194
195 SET sql_log_bin=0;
196 CALL mtr.add_suppression("Got fatal error .* from master when reading data from binary log: 'Error: connecting slave requested to start from GTID .*, which is not in the master's binlog'");
197 SET sql_log_bin=1;
198 --let $slave_io_errno= 1236
199 --source include/wait_for_slave_io_error.inc
200 --let $status_items= Slave_IO_State, Last_IO_Errno, Last_IO_Error, Using_Gtid
201 --source include/show_slave_status.inc
202
203 --let $rpl_only_running_threads= 1
204 --source include/stop_slave.inc
205 SET GLOBAL gtid_slave_pos = "0-1-3";
206 START SLAVE;
207 --source include/wait_for_slave_to_start.inc
208
209 --connection master
210 INSERT INTO t1 VALUES (6);
211 --source include/save_master_gtid.inc
212
213 --connection slave
214 --source include/sync_with_master_gtid.inc
215 SELECT * FROM t1 ORDER BY a;
216
217
218 --echo *** MDEV-4278: Slave does not detect that master is not GTID-aware ***
219
220 --connection slave
221 --source include/stop_slave.inc
222
223 --connection master
224 SET @old_dbug= @@global.DEBUG_DBUG;
225 SET GLOBAL debug_dbug="+d,simulate_non_gtid_aware_master";
226
227 --connection slave
228 START SLAVE;
229 --let $slave_io_errno= 1233
230 --source include/wait_for_slave_io_error.inc
231
232 --connection master
233 SET GLOBAL debug_dbug= @old_dbug;
234 INSERT INTO t1 VALUES (7);
235 --save_master_pos
236
237 --connection slave
238 START SLAVE;
239 --sync_with_master
240 SET sql_log_bin=0;
241 CALL mtr.add_suppression("The slave I/O thread stops because master does not support MariaDB global transaction id");
242 SET sql_log_bin=1;
243
244
245 --echo *** Test error during record_gtid() (non-xid cases) ***
246
247 --connection slave
248 --source include/stop_slave.inc
249
250 --connection master
251 CREATE TABLE t2 (a INT) ENGINE=MyISAM;
252 INSERT INTO t2 VALUES (1);
253 --save_master_pos
254
255 --connection slave
256 SET @old_dbug= @@global.DEBUG_DBUG;
257 SET GLOBAL debug_dbug="+d,gtid_inject_record_gtid";
258
259 START SLAVE;
260 --let $slave_sql_errno= 1942
261 --source include/wait_for_slave_sql_error.inc
262
263 SET GLOBAL debug_dbug= @old_dbug;
264
265 START SLAVE SQL_THREAD;
266 --sync_with_master
267
268 SELECT * FROM t2;
269 SET sql_log_bin=0;
270 CALL mtr.add_suppression("Slave: Could not update replication slave gtid state");
271 SET sql_log_bin=1;
272
273
274 --echo *** MDEV-4906: When event apply fails, next SQL thread start erroneously commits the failing GTID to gtid_slave_pos ***
275
276 --connection slave
277 --source include/stop_slave.inc
278 SET sql_log_bin=0;
279 DELETE FROM t2;
280 SET sql_log_bin=1;
281 SET @old_format=@@binlog_format;
282 SET GLOBAL binlog_format='row';
283 --source include/start_slave.inc
284
285 --connection master
286 SET @old_format=@@binlog_format;
287 SET binlog_format='row';
288 --let $gtid_pos1=`SELECT @@GLOBAL.gtid_binlog_pos`
289 DELETE FROM t2;
290 SET binlog_format=@old_format;
291 --save_master_pos
292
293 --connection slave
294 --let $slave_sql_errno= 1032
295 --source include/wait_for_slave_sql_error.inc
296 # Disable query to avoid result file update if precise GTID value changes.
297 --disable_query_log
298 SET @x=@@GLOBAL.gtid_slave_pos;
299 eval SELECT IF(@x='$gtid_pos1', "OK", CONCAT("ERROR: expected $gtid_pos1 got ", @x)) AS result;
300 --enable_query_log
301
302 # The bug was that upon restarting the SQL thread, the GTID for the
303 # failing event group was not cleared, so we would update it in the
304 # gtid_slave_pos as part of the first rotate event, corrupting the
305 # replication.
306 STOP SLAVE IO_THREAD;
307 START SLAVE;
308 --let $slave_sql_errno= 1032
309 --source include/wait_for_slave_sql_error.inc
310 # Disable query to avoid result file update if precise GTID value changes.
311 --disable_query_log
312 SET @x=@@GLOBAL.gtid_slave_pos;
313 eval SELECT IF(@x='$gtid_pos1', "OK", CONCAT("ERROR: expected $gtid_pos1 got ", @x)) AS result;
314 --enable_query_log
315
316 STOP SLAVE IO_THREAD;
317 SET sql_log_bin=0;
318 INSERT INTO t2 VALUES (1);
319 CALL mtr.add_suppression("Slave: Can't find record in 't2' Error_code: 1032");
320 SET sql_log_bin=1;
321 --source include/start_slave.inc
322 --sync_with_master
323 SET GLOBAL binlog_format=@old_format;
324
325 --connection master
326 DROP TABLE t1;
327 DROP TABLE t2;
328
329 call mtr.add_suppression("Can't find record in 't2'");
330
331 --source include/rpl_end.inc