| 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 |
| 9 |
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; |
| 10 |
|
| 11 |
SET @old_gtid_strict_mode= @@GLOBAL.gtid_strict_mode; |
| 12 |
SET GLOBAL gtid_strict_mode= 1; |
| 13 |
|
| 14 |
--connection server_2 |
| 15 |
--source include/stop_slave.inc |
| 16 |
SET @old_gtid_strict_mode= @@GLOBAL.gtid_strict_mode; |
| 17 |
SET GLOBAL gtid_strict_mode=1; |
| 18 |
CHANGE MASTER TO master_use_gtid=slave_pos; |
| 19 |
--source include/start_slave.inc |
| 20 |
|
| 21 |
--connection server_1 |
| 22 |
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; |
| 23 |
INSERT 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 |
| 31 |
CHANGE 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. |
| 37 |
INSERT INTO t1 VALUES (2); |
| 38 |
INSERT 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 |
| 47 |
eval 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 |
|
| 50 |
SELECT * FROM t1 ORDER BY a; |
| 51 |
|
| 52 |
--source include/stop_slave.inc |
| 53 |
CHANGE MASTER TO ignore_server_ids=(); |
| 54 |
--source include/start_slave.inc |
| 55 |
--sync_with_master |
| 56 |
--disable_query_log |
| 57 |
eval 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 |
|
| 60 |
SELECT * FROM t1 ORDER BY a; |
| 61 |
|
| 62 |
--connection server_1 |
| 63 |
INSERT INTO t1 VALUES (4); |
| 64 |
INSERT 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 |
| 71 |
eval SELECT IF(@@GLOBAL.gtid_slave_pos = '$gtid_pos', 'OK', CONCAT("ERROR: Expected $gtid_pos got ", @@GLOBAL.gtid_slave_pos)) AS RESULT; |
| 72 |
SELECT * 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 |
| 79 |
SET @old_dbug= @@GLOBAL.debug_dbug; |
| 80 |
SET GLOBAL debug_dbug= "+d,inject_slave_sql_before_apply_event"; |
| 81 |
CHANGE MASTER TO ignore_server_ids=(1); |
| 82 |
--source include/start_slave.inc |
| 83 |
|
| 84 |
--connection server_1 |
| 85 |
INSERT INTO t1 VALUES (6); |
| 86 |
INSERT 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. |
| 102 |
STOP SLAVE IO_THREAD; |
| 103 |
SET 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 |
| 109 |
eval 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) |
| 111 |
eval 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 |
| 116 |
CHANGE MASTER TO ignore_server_ids=(); |
| 117 |
SET GLOBAL debug_dbug= @old_dbug; |
| 118 |
--source include/start_slave.inc |
| 119 |
|
| 120 |
--connection server_1 |
| 121 |
INSERT INTO t1 VALUES (8); |
| 122 |
INSERT INTO t1 VALUES (9); |
| 123 |
--save_master_pos |
| 124 |
|
| 125 |
--connection server_2 |
| 126 |
--sync_with_master |
| 127 |
SELECT * FROM t1 ORDER BY a; |
| 128 |
|
| 129 |
# Clean up. |
| 130 |
--connection server_1 |
| 131 |
DROP TABLE t1; |
| 132 |
ALTER TABLE mysql.gtid_slave_pos ENGINE=Aria; |
| 133 |
SET GLOBAL gtid_strict_mode= @old_gtid_strict_mode; |
| 134 |
SET debug_sync = "reset"; |
| 135 |
|
| 136 |
--connection server_2 |
| 137 |
SET GLOBAL gtid_strict_mode= @old_gtid_strict_mode; |
| 138 |
SET debug_sync = "reset"; |
| 139 |
|
| 140 |
--source include/rpl_end.inc |
| 141 |
|