1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-34705: Binlog-in-engine: Protect against concurrent RESET MASTER and dump threads

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>
This commit is contained in:
Kristian Nielsen
2025-06-10 00:52:03 +02:00
parent d26851a575
commit 84da20e658
192 changed files with 789 additions and 53 deletions

View File

@@ -13,6 +13,7 @@ call mtr.add_suppression("Could not use master-bin for logging");
SET @old_debug= @@global.debug_dbug;
SELECT repeat('x',8192) INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug_46166.data';
SELECT repeat('x',10) INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug_46166-2.data';
include/kill_binlog_dump_threads.inc
RESET MASTER;
###################### TEST #1
FLUSH LOGS;
@@ -273,5 +274,6 @@ Note 1255 Slave already has been stopped
RESET SLAVE;
Warnings:
Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'No' to 'Slave_Pos'
include/kill_binlog_dump_threads.inc
RESET MASTER;
include/rpl_end.inc

View File

@@ -134,6 +134,7 @@ set @@global.binlog_checksum= IF(floor((rand()*1000)%2), "CRC32", "NONE");
flush logs;
connection master;
set @@global.binlog_checksum= CRC32;
include/kill_binlog_dump_threads.inc
reset master;
flush logs;
create table t3 (a int, b char(5));
@@ -148,6 +149,7 @@ include/stop_slave.inc
change master to master_host='127.0.0.1',master_port=MASTER_PORT, master_user='root';
connection master;
flush logs;
include/kill_binlog_dump_threads.inc
reset master;
insert into t3 value (1, @@global.binlog_checksum);
connection slave;

View File

@@ -197,6 +197,7 @@ connection server_1;
SET @old_state= @@GLOBAL.gtid_binlog_state;
SET GLOBAL gtid_binlog_state = '';
ERROR HY000: This operation is not allowed if any GTID has been logged to the binary log. Run RESET MASTER first to erase the log
include/kill_binlog_dump_threads.inc
RESET MASTER;
SET GLOBAL gtid_binlog_state = '';
FLUSH LOGS;

View File

@@ -65,6 +65,7 @@ Last_IO_Error = 'Got a packet bigger than 'slave_max_allowed_packet' bytes'
STOP SLAVE;
RESET SLAVE;
connection master;
include/kill_binlog_dump_threads.inc
RESET MASTER;
SET @max_allowed_packet_0= @@session.max_allowed_packet;
SHOW BINLOG EVENTS;

View File

@@ -20,6 +20,7 @@ include/reset_slave.inc
set global rpl_semi_sync_master_enabled= 0;
set global rpl_semi_sync_slave_enabled= 0;
connection master;
include/kill_binlog_dump_threads.inc
reset master;
set global rpl_semi_sync_master_enabled= 0;
set global rpl_semi_sync_slave_enabled= 0;
@@ -301,8 +302,10 @@ connection master;
create table t1 (a int) engine = ENGINE_TYPE;
drop table t1;
connection slave;
include/stop_slave.inc
[ test reset master ]
connection master;
include/kill_binlog_dump_threads.inc
reset master;
show status like 'Rpl_semi_sync_master_status';
Variable_name Value
@@ -314,7 +317,6 @@ show status like 'Rpl_semi_sync_master_yes_tx';
Variable_name Value
Rpl_semi_sync_master_yes_tx 0
connection slave;
include/stop_slave.inc
include/reset_slave.inc
include/kill_binlog_dump_threads.inc
connection slave;
@@ -349,6 +351,7 @@ connection slave;
include/stop_slave.inc
include/reset_slave.inc
connection master;
include/kill_binlog_dump_threads.inc
reset master;
include/kill_binlog_dump_threads.inc
set sql_log_bin=0;