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