mariadb/mysql-test/suite/rpl/t/rpl_gtid_startpos.test
unknown 9bb989a9d1 MDEV-26: Global transaction ID.
Fix MDEV-4275 - I/O thread restart duplicates events in the relay log.
The first time we connect to master after CHANGE MASTER or restart, we connect
from the GTID position. But then subsequent reconnects or IO thread restarts
reconnect with the old-style file/offset binlog pos from where it left off at
last disconnect. This is necessary to avoid duplicate events in the relay
logs, as there is nothing that synchronises the SQL thread update of GTID
state (multiple threads in case of multi-source) with IO thread reconnects.

Test cases.

Some small cleanups and fixes.
2013-03-21 11:03:31 +01:00

151 lines
4.1 KiB
Text

--source include/have_innodb.inc
--let $rpl_topology=1->2
--source include/rpl_init.inc
--echo *** Test connecting with empty GTID state to start from very beginning of binlog ***
--connection server_2
--source include/stop_slave.inc
RESET MASTER;
RESET SLAVE;
--connection server_1
RESET MASTER;
# Create an empty binlog file, to check that empty binlog state is handled correctly.
FLUSH LOGS;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
--save_master_pos
--connection server_2
--replace_result $MASTER_MYPORT MASTER_PORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
MASTER_GTID_POS="";
--source include/start_slave.inc
--sync_with_master
SELECT * FROM t1;
--connection server_1
INSERT INTO t1 VALUES (1);
--save_master_pos
--connection server_2
--sync_with_master
SELECT * FROM t1;
--source include/stop_slave.inc
--echo *** Test that master gives error when slave asks for empty gtid pos and binlog files have been purged. ***
--connection server_1
FLUSH LOGS;
INSERT INTO t1 VALUES (2);
--save_master_pos
PURGE BINARY LOGS TO 'master-bin.000003';
--source include/show_binary_logs.inc
--connection server_2
--replace_result $MASTER_MYPORT MASTER_PORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
MASTER_GTID_POS="";
START SLAVE;
--let $slave_io_errno= 1236
--source include/wait_for_slave_io_error.inc
--source include/stop_slave.inc
--replace_result $MASTER_MYPORT MASTER_PORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
MASTER_LOG_FILE="master-bin.000003", MASTER_LOG_POS=4;
--source include/start_slave.inc
--sync_with_master
SELECT * FROM t1 ORDER BY a;
SET sql_log_bin=0;
call mtr.add_suppression('Could not find GTID state requested by slave in any binlog files');
SET sql_log_bin=1;
--echo *** Test that we give error when explict MASTER_GTID_POS=xxx that conflicts with what is in our binary log ***
--source include/stop_slave.inc
--connection server_1
INSERT INTO t1 VALUES(3);
--connection server_2
--replace_result $MASTER_MYPORT MASTER_PORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
MASTER_GTID_POS='0-1-3';
--source include/start_slave.inc
--let $wait_condition= SELECT COUNT(*) = 3 FROM t1
--source include/wait_condition.inc
SELECT * FROM t1 ORDER by a;
--source include/stop_slave.inc
--connection server_1
INSERT INTO t1 VALUES (4);
--connection server_2
# Now add some local transactions that conflict with the GTID position
# being set for MASTER_GTID_POS.
INSERT INTO t1 VALUES (10);
DELETE FROM t1 WHERE a=10;
--replace_result $MASTER_MYPORT MASTER_PORT
--error ER_MASTER_GTID_POS_CONFLICTS_WITH_BINLOG
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
MASTER_GTID_POS='0-1-4';
# Try again after RESET MASTER to remove the conflicting binlog.
RESET MASTER;
--replace_result $MASTER_MYPORT MASTER_PORT
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
MASTER_GTID_POS='0-1-4';
START SLAVE;
--let $wait_condition= SELECT COUNT(*) = 4 FROM t1
--source include/wait_condition.inc
SELECT * FROM t1 ORDER by a;
--connection server_1
DROP TABLE t1;
--save_master_pos
--connection server_2
--sync_with_master
--echo *** MDEV-4275: I/O thread restart duplicates events in relay log ***
--connection server_2
--source include/stop_slave.inc
RESET SLAVE ALL;
RESET MASTER;
--connection server_1
RESET MASTER;
--connection server_2
--replace_result $MASTER_MYPORT MASTER_PORT
eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$MASTER_MYPORT, master_user='root', master_gtid_pos='';
--source include/start_slave.inc
--connection server_1
CREATE TABLE t1 (a INT PRIMARY KEY);
INSERT INTO t1 VALUES (1);
--save_master_pos
--connection server_2
--sync_with_master
SELECT * FROM t1;
--source include/stop_slave_io.inc
START SLAVE IO_THREAD;
--source include/wait_for_slave_io_to_start.inc
--connection server_1
INSERT INTO t1 VALUES (2);
--save_master_pos
--connection server_2
--sync_with_master
SELECT * FROM t1 ORDER BY a;
# Clean up.
--connection server_1
DROP TABLE t1;
--source include/rpl_end.inc