mirror of
https://github.com/MariaDB/server.git
synced 2025-09-10 19:40:17 +02:00

This is actually an existing problem in the old binlog implementation, and this patch is applicable to old binlog also. The problem is that RESET MASTER can run concurrently with binlog dump threads / connected slaves. This will remove the binlog from under the feet of the reader, which can cause all sorts of strange behaviour. This patch fixes the problem by disallowing to run RESET MASTER when dump threads (or other RESET MASTER or SHOW BINARY LOGS) are running. An error is thrown in this case, user must stop slaves and/or kill dump threads to make the RESET MASTER go through. A slave that connects in the middle of RESET MASTER will wait for it to complete. Fix a lot of test cases to kill any lingering dump threads before doing RESET MASTER, mostly just by sourcing include/kill_binlog_dump_threads.inc. Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
119 lines
3.4 KiB
Text
119 lines
3.4 KiB
Text
--let $rpl_topology=1->2
|
|
--source include/rpl_init.inc
|
|
|
|
--connection server_2
|
|
--source include/stop_slave.inc
|
|
SET @slave_old_strict= @@GLOBAL.gtid_strict_mode;
|
|
SET GLOBAL gtid_strict_mode= 1;
|
|
CHANGE MASTER TO master_use_gtid=slave_pos;
|
|
--source include/start_slave.inc
|
|
|
|
--connection server_1
|
|
SET @master_old_strict= @@GLOBAL.gtid_strict_mode;
|
|
SET GLOBAL gtid_strict_mode= 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 ORDER BY a;
|
|
|
|
--source include/stop_slave.inc
|
|
|
|
--connection server_1
|
|
INSERT INTO t1 VALUES (2);
|
|
INSERT INTO t1 VALUES (3);
|
|
--let $old_gtid_pos= `SELECT @@GLOBAL.gtid_current_pos`
|
|
--source include/kill_binlog_dump_threads.inc
|
|
RESET MASTER;
|
|
--replace_result $old_gtid_pos OLD_GTID_POS
|
|
eval SET GLOBAL gtid_slave_pos= '$old_gtid_pos';
|
|
|
|
--connection server_2
|
|
--source include/start_slave.inc
|
|
|
|
--connection server_1
|
|
INSERT INTO t1 VALUES (4);
|
|
--source include/save_master_gtid.inc
|
|
|
|
--connection server_2
|
|
SET sql_log_bin= 0;
|
|
CALL mtr.add_suppression("The binlog on the master is missing the GTID");
|
|
SET sql_log_bin= 1;
|
|
--let $slave_io_errno=1236
|
|
--source include/wait_for_slave_io_error.inc
|
|
|
|
STOP SLAVE SQL_THREAD;
|
|
--replace_result $old_gtid_pos OLD_GTID_POS
|
|
eval SET GLOBAL gtid_slave_pos= '$old_gtid_pos';
|
|
|
|
--source include/start_slave.inc
|
|
--source include/sync_with_master_gtid.inc
|
|
SELECT * FROM t1 ORDER BY a;
|
|
|
|
--source include/stop_slave.inc
|
|
RESET SLAVE ALL;
|
|
RESET MASTER;
|
|
SET GLOBAL gtid_slave_pos= '0-2-10';
|
|
|
|
--connection server_1
|
|
--replace_result $SERVER_MYPORT_2 SERVER_MYPORT_2
|
|
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_2,
|
|
master_user= 'root', master_ssl_verify_server_cert=0, master_use_gtid=CURRENT_POS;
|
|
START SLAVE;
|
|
|
|
--connection server_2
|
|
INSERT INTO t1 VALUES (11);
|
|
--save_master_pos
|
|
|
|
--connection server_1
|
|
SET sql_log_bin= 0;
|
|
CALL mtr.add_suppression("which is not in the master's binlog. Since the master's binlog contains GTIDs with higher sequence numbers, it probably means that the slave has diverged");
|
|
SET sql_log_bin= 1;
|
|
--let $slave_io_errno=1236
|
|
--source include/wait_for_slave_io_error.inc
|
|
|
|
--connection server_1
|
|
STOP SLAVE SQL_THREAD;
|
|
SET GLOBAL gtid_slave_pos= '0-2-10';
|
|
SET GLOBAL gtid_strict_mode= 0;
|
|
--source include/start_slave.inc
|
|
--sync_with_master
|
|
SELECT * FROM t1 ORDER BY a;
|
|
|
|
--source include/stop_slave.inc
|
|
RESET SLAVE ALL;
|
|
--let $old_gtid_pos= `SELECT @@GLOBAL.gtid_current_pos`
|
|
INSERT INTO t1 VALUES (12);
|
|
--save_master_pos
|
|
|
|
--connection server_2
|
|
INSERT INTO t1 VALUES (22);
|
|
--replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1
|
|
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_1,
|
|
master_user= 'root', master_use_gtid=CURRENT_POS;
|
|
START SLAVE;
|
|
SET sql_log_bin= 0;
|
|
CALL mtr.add_suppression("which is not in the master's binlog. Since the master's binlog contains GTIDs with higher sequence numbers, it probably means that the slave has diverged");
|
|
SET sql_log_bin= 1;
|
|
--let $slave_io_errno=1236
|
|
--source include/wait_for_slave_io_error.inc
|
|
STOP SLAVE SQL_THREAD;
|
|
SET GLOBAL gtid_strict_mode= 0;
|
|
CHANGE MASTER TO master_use_gtid=SLAVE_POS;
|
|
--replace_result $old_gtid_pos OLD_GTID_POS
|
|
eval SET GLOBAL gtid_slave_pos= '$old_gtid_pos';
|
|
--source include/start_slave.inc
|
|
--sync_with_master
|
|
SELECT * FROM t1 ORDER BY a;
|
|
|
|
# Clean up.
|
|
--connection server_2
|
|
SET GLOBAL gtid_strict_mode= @slave_old_strict;
|
|
|
|
--connection server_1
|
|
DROP TABLE t1;
|
|
SET GLOBAL gtid_strict_mode= @master_old_strict;
|
|
|
|
--source include/rpl_end.inc
|