mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03: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>
208 lines
7.3 KiB
Plaintext
208 lines
7.3 KiB
Plaintext
include/master-slave.inc
|
|
[connection master]
|
|
connection slave;
|
|
include/stop_slave.inc
|
|
CHANGE MASTER TO MASTER_USE_GTID=NO;
|
|
include/start_slave.inc
|
|
connection master;
|
|
call mtr.add_suppression('Slave can not handle replication events with the checksum that master is configured to log');
|
|
call mtr.add_suppression('Replication event checksum verification failed');
|
|
call mtr.add_suppression('Relay log write failure: could not queue event from master');
|
|
call mtr.add_suppression('Master is configured to log replication events with checksum, but will not send such events to slaves that cannot process them');
|
|
connection master;
|
|
set @master_save_binlog_checksum= @@global.binlog_checksum;
|
|
set @save_master_verify_checksum = @@global.master_verify_checksum;
|
|
select @@global.binlog_checksum as 'must be CRC32 because of the command line option';
|
|
must be CRC32 because of the command line option
|
|
CRC32
|
|
select @@session.binlog_checksum as 'no session var';
|
|
ERROR HY000: Variable 'binlog_checksum' is a GLOBAL variable
|
|
select @@global.master_verify_checksum as 'must be zero because of default';
|
|
must be zero because of default
|
|
0
|
|
select @@session.master_verify_checksum as 'no session var';
|
|
ERROR HY000: Variable 'master_verify_checksum' is a GLOBAL variable
|
|
connection slave;
|
|
set @slave_save_binlog_checksum= @@global.binlog_checksum;
|
|
set @save_slave_sql_verify_checksum = @@global.slave_sql_verify_checksum;
|
|
select @@global.slave_sql_verify_checksum as 'must be one because of default';
|
|
must be one because of default
|
|
1
|
|
select @@session.slave_sql_verify_checksum as 'no session var';
|
|
ERROR HY000: Variable 'slave_sql_verify_checksum' is a GLOBAL variable
|
|
connection master;
|
|
show binary logs;
|
|
Log_name File_size
|
|
master-bin.000001 #
|
|
set @@global.binlog_checksum = NONE;
|
|
select @@global.binlog_checksum;
|
|
@@global.binlog_checksum
|
|
NONE
|
|
*** must be rotations seen ***
|
|
show binary logs;
|
|
Log_name File_size
|
|
master-bin.000001 #
|
|
master-bin.000002 #
|
|
set @@global.binlog_checksum = default;
|
|
select @@global.binlog_checksum;
|
|
@@global.binlog_checksum
|
|
CRC32
|
|
set @@global.binlog_checksum = CRC32;
|
|
select @@global.binlog_checksum;
|
|
@@global.binlog_checksum
|
|
CRC32
|
|
set @@global.binlog_checksum = CRC32;
|
|
set @@global.master_verify_checksum = 0;
|
|
set @@global.master_verify_checksum = default;
|
|
set @@global.binlog_checksum = ADLER32;
|
|
ERROR 42000: Variable 'binlog_checksum' can't be set to the value of 'ADLER32'
|
|
set @@global.master_verify_checksum = 2;
|
|
ERROR 42000: Variable 'master_verify_checksum' can't be set to the value of '2'
|
|
connection slave;
|
|
set @@global.slave_sql_verify_checksum = 0;
|
|
set @@global.slave_sql_verify_checksum = default;
|
|
set @@global.slave_sql_verify_checksum = 2;
|
|
ERROR 42000: Variable 'slave_sql_verify_checksum' can't be set to the value of '2'
|
|
connection master;
|
|
set @@global.binlog_checksum = NONE;
|
|
create table t1 (a int);
|
|
flush logs;
|
|
flush logs;
|
|
flush logs;
|
|
connection slave;
|
|
flush logs;
|
|
flush logs;
|
|
flush logs;
|
|
select count(*) as zero from t1;
|
|
zero
|
|
0
|
|
include/stop_slave.inc
|
|
connection master;
|
|
set @@global.binlog_checksum = CRC32;
|
|
insert into t1 values (1) /* will not be applied on slave due to simulation */;
|
|
connection slave;
|
|
set @saved_dbug = @@global.debug_dbug;
|
|
set @@global.debug_dbug='d,simulate_slave_unaware_checksum';
|
|
start slave;
|
|
include/wait_for_slave_io_error.inc [errno=1236]
|
|
Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'Slave can not handle replication events with the checksum that master is configured to log; the first event 'master-bin.000009' at 411, the last event read from 'master-bin.000010' at 4, the last byte read from 'master-bin.000010' at 256.''
|
|
select count(*) as zero from t1;
|
|
zero
|
|
0
|
|
set @@global.debug_dbug = @saved_dbug;
|
|
connection slave;
|
|
include/start_slave.inc
|
|
connection master;
|
|
set @@global.master_verify_checksum = 1;
|
|
set @save_dbug = @@session.debug_dbug;
|
|
set @@session.debug_dbug='d,simulate_checksum_test_failure';
|
|
show binlog events;
|
|
ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error
|
|
SET debug_dbug= @save_dbug;
|
|
set @@global.master_verify_checksum = default;
|
|
connection slave;
|
|
connection slave;
|
|
include/stop_slave.inc
|
|
connection master;
|
|
create table t2 (a int);
|
|
connection slave;
|
|
set @saved_dbug = @@global.debug_dbug;
|
|
set @@global.debug_dbug='d,simulate_checksum_test_failure';
|
|
start slave io_thread;
|
|
include/wait_for_slave_io_error.inc [errno=1595,1913]
|
|
set @@global.debug_dbug = @saved_dbug;
|
|
start slave io_thread;
|
|
include/wait_for_slave_param.inc [Read_Master_Log_Pos]
|
|
set @@global.slave_sql_verify_checksum = 1;
|
|
set @@global.debug_dbug='d,simulate_checksum_test_failure';
|
|
start slave sql_thread;
|
|
include/wait_for_slave_sql_error.inc [errno=1593]
|
|
Last_SQL_Error = 'Error initializing relay log position: I/O error reading event at position 4'
|
|
set @@global.debug_dbug = @saved_dbug;
|
|
include/start_slave.inc
|
|
connection master;
|
|
connection slave;
|
|
select count(*) as 'must be zero' from t2;
|
|
must be zero
|
|
0
|
|
connection slave;
|
|
stop slave;
|
|
include/reset_slave.inc
|
|
Warnings:
|
|
Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'No' to 'Slave_Pos'
|
|
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));
|
|
connection slave;
|
|
include/start_slave.inc
|
|
connection master;
|
|
connection slave;
|
|
select count(*) as 'must be zero' from t3;
|
|
must be zero
|
|
0
|
|
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;
|
|
include/start_slave.inc
|
|
flush logs;
|
|
connection master;
|
|
connection slave;
|
|
select count(*) as 'must be one' from t3;
|
|
must be one
|
|
1
|
|
connection master;
|
|
set @@global.binlog_checksum= IF(floor((rand()*1000)%2), "CRC32", "NONE");
|
|
insert into t3 value (1, @@global.binlog_checksum);
|
|
connection slave;
|
|
connection master;
|
|
drop table t1, t2, t3;
|
|
set @@global.binlog_checksum = @master_save_binlog_checksum;
|
|
set @@global.master_verify_checksum = @save_master_verify_checksum;
|
|
connection slave;
|
|
*** Bug#59123 / MDEV-5799: INCIDENT_EVENT checksum written to error log as garbage characters ***
|
|
connection master;
|
|
CREATE TABLE t4 (a INT PRIMARY KEY);
|
|
INSERT INTO t4 VALUES (1);
|
|
SET sql_log_bin=0;
|
|
CALL mtr.add_suppression("\\[ERROR\\] Can't generate a unique log-filename");
|
|
SET sql_log_bin=1;
|
|
SET @old_dbug= @@GLOBAL.debug_dbug;
|
|
SET debug_dbug= '+d,binlog_inject_new_name_error';
|
|
FLUSH LOGS;
|
|
ERROR HY000: Can't generate a unique log-filename master-bin.(1-999)
|
|
SET debug_dbug= @old_dbug;
|
|
INSERT INTO t4 VALUES (2);
|
|
connection slave;
|
|
include/wait_for_slave_sql_error.inc [errno=1590]
|
|
Last_SQL_Error = 'The incident LOST_EVENTS occurred on the master. Message: error writing to the binary log'
|
|
FOUND 1 /Slave SQL: The incident LOST_EVENTS occurred on the master\. Message: error writing to the binary log, Internal MariaDB error code: 1590/ in mysqld.2.err
|
|
SELECT * FROM t4 ORDER BY a;
|
|
a
|
|
1
|
|
STOP SLAVE IO_THREAD;
|
|
SET sql_slave_skip_counter= 1;
|
|
include/start_slave.inc
|
|
connection master;
|
|
connection slave;
|
|
SELECT * FROM t4 ORDER BY a;
|
|
a
|
|
1
|
|
2
|
|
connection slave;
|
|
set @@global.binlog_checksum = @slave_save_binlog_checksum;
|
|
set @@global.slave_sql_verify_checksum = @save_slave_sql_verify_checksum;
|
|
End of tests
|
|
connection master;
|
|
DROP TABLE t4;
|
|
include/rpl_end.inc
|