mirror of
https://github.com/MariaDB/server.git
synced 2025-10-29 09:56:12 +01: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>
171 lines
4.6 KiB
Text
171 lines
4.6 KiB
Text
connection node_2;
|
|
connection node_1;
|
|
connect replica, 127.0.0.1, root, , test, $NODE_MYPORT_2;
|
|
connect primary, 127.0.0.1, root, , test, $NODE_MYPORT_3;
|
|
create user repl@'%' identified by 'repl';
|
|
grant all on *.* to repl@'%';
|
|
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
|
|
connection node_1;
|
|
connection replica;
|
|
connection primary;
|
|
connection replica;
|
|
START SLAVE;
|
|
connection primary;
|
|
CREATE TABLE t1 (id bigint auto_increment primary key, msg varchar(100)) engine=innodb;
|
|
# Intentionally generate 1k GTID-events
|
|
SELECT COUNT(*) AS EXPECT_1000 FROM t1;
|
|
EXPECT_1000
|
|
1000
|
|
connection replica;
|
|
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
|
|
EXPECT_1
|
|
1
|
|
SELECT COUNT(*) < 1000 AS EXPECT_1 FROM mysql.gtid_slave_pos;
|
|
EXPECT_1
|
|
1
|
|
SELECT @@gtid_slave_pos,@@gtid_binlog_pos,@@gtid_current_pos;
|
|
@@gtid_slave_pos @@gtid_binlog_pos @@gtid_current_pos
|
|
0-3-1004 0-3-1004 0-3-1004
|
|
SELECT COUNT(*) AS EXPECT_1000 FROM t1;
|
|
EXPECT_1000
|
|
1000
|
|
connection node_1;
|
|
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
|
|
EXPECT_1
|
|
1
|
|
SELECT COUNT(*) < 1000 AS EXPECT_1 FROM mysql.gtid_slave_pos;
|
|
EXPECT_1
|
|
1
|
|
SELECT @@gtid_slave_pos,@@gtid_binlog_pos,@@gtid_current_pos;
|
|
@@gtid_slave_pos @@gtid_binlog_pos @@gtid_current_pos
|
|
0-3-1004 0-3-1004 0-3-1004
|
|
SELECT COUNT(*) AS EXPECT_1000 FROM t1;
|
|
EXPECT_1000
|
|
1000
|
|
connection replica;
|
|
# Verify that graceful shutdown succeeds in replica.
|
|
# Force SST
|
|
connection node_1;
|
|
# Waiting until replica is not part of cluster anymore
|
|
connection replica;
|
|
# Start replica again
|
|
# Wait until replica is back on cluster
|
|
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
|
|
EXPECT_1
|
|
1
|
|
SELECT COUNT(*) < 1000 AS EXPECT_1 FROM mysql.gtid_slave_pos;
|
|
EXPECT_1
|
|
1
|
|
SELECT @@gtid_slave_pos,@@gtid_binlog_pos,@@gtid_current_pos;
|
|
@@gtid_slave_pos @@gtid_binlog_pos @@gtid_current_pos
|
|
0-3-1004 0-3-1004 0-3-1004
|
|
SELECT COUNT(*) AS EXPECT_1000 FROM t1;
|
|
EXPECT_1000
|
|
1000
|
|
connection node_1;
|
|
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
|
|
EXPECT_1
|
|
1
|
|
SELECT COUNT(*) < 1000 AS EXPECT_1 FROM mysql.gtid_slave_pos;
|
|
EXPECT_1
|
|
1
|
|
SELECT @@gtid_slave_pos,@@gtid_binlog_pos,@@gtid_current_pos;
|
|
@@gtid_slave_pos @@gtid_binlog_pos @@gtid_current_pos
|
|
0-3-1004 0-3-1004 0-3-1004
|
|
SELECT COUNT(*) AS EXPECT_1000 FROM t1;
|
|
EXPECT_1000
|
|
1000
|
|
connection primary;
|
|
SELECT COUNT(*) AS EXPECT_1000 FROM t1;
|
|
EXPECT_1000
|
|
1000
|
|
drop table t1;
|
|
connection replica;
|
|
connection node_1;
|
|
connection primary;
|
|
CREATE TABLE t1 (id bigint auto_increment primary key, msg varchar(100)) engine=innodb;
|
|
# Intentionally generate 1k GTID-events
|
|
SELECT COUNT(*) AS EXPECT_1000 FROM t1;
|
|
EXPECT_1000
|
|
1000
|
|
connection replica;
|
|
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
|
|
EXPECT_1
|
|
1
|
|
SELECT COUNT(*) < 1000 AS EXPECT_1 FROM mysql.gtid_slave_pos;
|
|
EXPECT_1
|
|
1
|
|
SELECT @@gtid_slave_pos,@@gtid_binlog_pos,@@gtid_current_pos;
|
|
@@gtid_slave_pos @@gtid_binlog_pos @@gtid_current_pos
|
|
0-3-2006 0-3-2006 0-3-2006
|
|
SELECT COUNT(*) AS EXPECT_1000 FROM t1;
|
|
EXPECT_1000
|
|
1000
|
|
connection node_1;
|
|
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
|
|
EXPECT_1
|
|
1
|
|
SELECT COUNT(*) < 1000 AS EXPECT_1 FROM mysql.gtid_slave_pos;
|
|
EXPECT_1
|
|
1
|
|
SELECT @@gtid_slave_pos,@@gtid_binlog_pos,@@gtid_current_pos;
|
|
@@gtid_slave_pos @@gtid_binlog_pos @@gtid_current_pos
|
|
0-3-2006 0-3-2006 0-3-2006
|
|
connection replica;
|
|
# Verify that graceful shutdown succeeds in replica.
|
|
# Force SST
|
|
connection node_1;
|
|
# Waiting until replica is not part of cluster anymore
|
|
# Add writes to primary
|
|
connection primary;
|
|
# Intentionally generate 1k GTID-events
|
|
SELECT COUNT(*) AS EXPECT_2000 FROM t1;
|
|
EXPECT_2000
|
|
2000
|
|
connection replica;
|
|
# Start replica again
|
|
# Wait until replica is back on cluster
|
|
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
|
|
EXPECT_1
|
|
1
|
|
SELECT COUNT(*) < 1000 AS EXPECT_1 FROM mysql.gtid_slave_pos;
|
|
EXPECT_1
|
|
1
|
|
SELECT @@gtid_slave_pos,@@gtid_binlog_pos,@@gtid_current_pos;
|
|
@@gtid_slave_pos @@gtid_binlog_pos @@gtid_current_pos
|
|
0-3-3006 0-3-3006 0-3-3006
|
|
SELECT COUNT(*) AS EXPECT_2000 FROM t1;
|
|
EXPECT_2000
|
|
2000
|
|
connection node_1;
|
|
SELECT COUNT(*) > 0 AS EXPECT_1 FROM mysql.gtid_slave_pos;
|
|
EXPECT_1
|
|
1
|
|
SELECT COUNT(*) < 1000 AS EXPECT_1 FROM mysql.gtid_slave_pos;
|
|
EXPECT_1
|
|
1
|
|
SELECT @@gtid_slave_pos,@@gtid_binlog_pos,@@gtid_current_pos;
|
|
@@gtid_slave_pos @@gtid_binlog_pos @@gtid_current_pos
|
|
0-3-3006 0-3-3006 0-3-3006
|
|
SELECT COUNT(*) AS EXPECT_2000 FROM t1;
|
|
EXPECT_2000
|
|
2000
|
|
connection primary;
|
|
SELECT COUNT(*) AS EXPECT_2000 FROM t1;
|
|
EXPECT_2000
|
|
2000
|
|
drop table t1;
|
|
connection replica;
|
|
connection node_1;
|
|
connection replica;
|
|
STOP SLAVE;
|
|
RESET SLAVE ALL;
|
|
connection primary;
|
|
include/kill_binlog_dump_threads.inc
|
|
RESET MASTER;
|
|
connection node_1;
|
|
disconnect primary;
|
|
disconnect replica;
|
|
disconnect node_2;
|
|
disconnect node_1;
|
|
# End of test
|