1--source include/have_innodb.inc 2--source include/have_debug.inc 3--source include/have_debug_sync.inc 4 5--let $rpl_topology=1->2 6--source include/rpl_init.inc 7 8--connection server_1 9ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; 10 11SET @old_gtid_strict_mode= @@GLOBAL.gtid_strict_mode; 12SET GLOBAL gtid_strict_mode= 1; 13 14--connection server_2 15--source include/stop_slave.inc 16SET @old_gtid_strict_mode= @@GLOBAL.gtid_strict_mode; 17SET GLOBAL gtid_strict_mode=1; 18CHANGE MASTER TO master_use_gtid=slave_pos; 19--source include/start_slave.inc 20 21--connection server_1 22CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; 23INSERT INTO t1 VALUES (1); 24--save_master_pos 25 26--connection server_2 27--sync_with_master 28 29--echo **** MDEV-4488: GTID position should be updated for events that are ignored due to server id *** 30--source include/stop_slave.inc 31CHANGE MASTER TO ignore_server_ids=(1); 32--source include/start_slave.inc 33 34--connection server_1 35# These inserts should be ignored (not applied) on the slave, but the 36# gtid_slave_pos should still be updated. 37INSERT INTO t1 VALUES (2); 38INSERT INTO t1 VALUES (3); 39--save_master_pos 40--let gtid_pos=`SELECT @@GLOBAL.gtid_binlog_pos` 41 42--connection server_2 43--sync_with_master 44--let $wait_condition= SELECT @@GLOBAL.gtid_slave_pos = '$gtid_pos' 45--source include/wait_condition.inc 46--disable_query_log 47eval SELECT IF(@@GLOBAL.gtid_slave_pos = '$gtid_pos', 'OK', CONCAT("ERROR: Expected $gtid_pos got ", @@GLOBAL.gtid_slave_pos)) AS RESULT; 48--enable_query_log 49 50SELECT * FROM t1 ORDER BY a; 51 52--source include/stop_slave.inc 53CHANGE MASTER TO ignore_server_ids=(); 54--source include/start_slave.inc 55--sync_with_master 56--disable_query_log 57eval SELECT IF(@@GLOBAL.gtid_slave_pos = '$gtid_pos', 'OK', CONCAT("ERROR: Expected $gtid_pos got ", @@GLOBAL.gtid_slave_pos)) AS RESULT; 58--enable_query_log 59 60SELECT * FROM t1 ORDER BY a; 61 62--connection server_1 63INSERT INTO t1 VALUES (4); 64INSERT INTO t1 VALUES (5); 65--let gtid_pos=`SELECT @@GLOBAL.gtid_binlog_pos` 66--save_master_pos 67 68--connection server_2 69--sync_with_master 70--disable_query_log 71eval SELECT IF(@@GLOBAL.gtid_slave_pos = '$gtid_pos', 'OK', CONCAT("ERROR: Expected $gtid_pos got ", @@GLOBAL.gtid_slave_pos)) AS RESULT; 72SELECT * FROM t1 ORDER BY a; 73--enable_query_log 74 75 76--echo *** Test the same thing when IO thread exits before SQL thread reaches end of log. *** 77--connection server_2 78--source include/stop_slave.inc 79SET @old_dbug= @@GLOBAL.debug_dbug; 80SET GLOBAL debug_dbug= "+d,inject_slave_sql_before_apply_event"; 81CHANGE MASTER TO ignore_server_ids=(1); 82--source include/start_slave.inc 83 84--connection server_1 85INSERT INTO t1 VALUES (6); 86INSERT INTO t1 VALUES (7); 87--let $master_pos= query_get_value(SHOW MASTER STATUS, Position, 1) 88--let gtid_pos=`SELECT @@GLOBAL.gtid_binlog_pos` 89--save_master_pos 90 91--connection server_2 92# Wait for IO thread to have read all events from master, and for SQL thread to 93# sit in the debug_sync point. 94 95--let $slave_param= Read_Master_Log_Pos 96--let $slave_param_value= $master_pos 97--source include/wait_for_slave_param.inc 98 99# Now stop the IO thread, and let the SQL thread continue. The IO thread 100# should write a Gtid_list event that the SQL thread can use to update the 101# gtid_slave_pos with the GTIDs of the skipped events. 102STOP SLAVE IO_THREAD; 103SET debug_sync = "now SIGNAL continue"; 104 105--sync_with_master 106--let $wait_condition= SELECT @@GLOBAL.gtid_slave_pos = '$gtid_pos' 107--source include/wait_condition.inc 108--disable_query_log 109eval SELECT IF(@@GLOBAL.gtid_slave_pos = '$gtid_pos', 'OK', CONCAT("ERROR: Expected $gtid_pos got ", @@GLOBAL.gtid_slave_pos)) AS RESULT; 110--let $slave_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1) 111eval SELECT IF('$slave_pos' = '$master_pos', 'OK', "ERROR: Expected $master_pos got $slave_pos") AS RESULT; 112--enable_query_log 113 114 115--source include/stop_slave.inc 116CHANGE MASTER TO ignore_server_ids=(); 117SET GLOBAL debug_dbug= @old_dbug; 118--source include/start_slave.inc 119 120--connection server_1 121INSERT INTO t1 VALUES (8); 122INSERT INTO t1 VALUES (9); 123--save_master_pos 124 125--connection server_2 126--sync_with_master 127SELECT * FROM t1 ORDER BY a; 128 129# Clean up. 130--connection server_1 131DROP TABLE t1; 132ALTER TABLE mysql.gtid_slave_pos ENGINE=Aria; 133SET GLOBAL gtid_strict_mode= @old_gtid_strict_mode; 134SET debug_sync = "reset"; 135 136--connection server_2 137SET GLOBAL gtid_strict_mode= @old_gtid_strict_mode; 138SET debug_sync = "reset"; 139 140--source include/rpl_end.inc 141 142