mirror of
https://github.com/MariaDB/server.git
synced 2025-01-30 18:41:56 +01:00
5aaf73fcaa
Add tests crashing the slave in the middle of replication and checking that replication picks-up again on restart in a crash-safe way. Fix silly code that causes crash by inserting uninitialised data into a hash.
91 lines
2.5 KiB
Text
91 lines
2.5 KiB
Text
include/rpl_init.inc [topology=1->2]
|
|
*** Test crashing master, causing slave IO thread to reconnect while SQL thread is running ***
|
|
ALTER TABLE mysql.rpl_slave_state ENGINE=InnoDB;
|
|
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
|
|
INSERT INTO t1 VALUES (1, 0);
|
|
include/stop_slave.inc
|
|
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
|
|
MASTER_GTID_POS=AUTO;
|
|
INSERT INTO t1 VALUES (2,1);
|
|
INSERT INTO t1 VALUES (3,1);
|
|
include/start_slave.inc
|
|
SET SESSION debug_dbug="+d,crash_dispatch_command_before";
|
|
SELECT 1;
|
|
Got one of the listed errors
|
|
INSERT INTO t1 VALUES (1000, 3);
|
|
DROP TABLE t1;
|
|
*** Test crashing the master mysqld and check that binlog state is recovered. ***
|
|
include/stop_slave.inc
|
|
RESET MASTER;
|
|
CHANGE MASTER TO master_gtid_pos='';
|
|
RESET MASTER;
|
|
SHOW BINLOG EVENTS IN 'master-bin.000001' LIMIT 1,1;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
master-bin.000001 # Gtid_list # # []
|
|
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
|
|
include/start_slave.inc
|
|
SET gtid_domain_id= 1;
|
|
INSERT INTO t1 VALUES (1);
|
|
INSERT INTO t1 VALUES (2);
|
|
FLUSH LOGS;
|
|
SET gtid_domain_id= 2;
|
|
INSERT INTO t1 VALUES (3);
|
|
FLUSH LOGS;
|
|
show binary logs;
|
|
Log_name File_size
|
|
master-bin.000001 #
|
|
master-bin.000002 #
|
|
master-bin.000003 #
|
|
SHOW BINLOG EVENTS IN 'master-bin.000003' LIMIT 1,1;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
master-bin.000003 # Gtid_list # # [1-1-3,2-1-4,0-1-1]
|
|
SET SESSION debug_dbug="+d,crash_dispatch_command_before";
|
|
SELECT 1;
|
|
Got one of the listed errors
|
|
show binary logs;
|
|
Log_name File_size
|
|
master-bin.000001 #
|
|
master-bin.000002 #
|
|
master-bin.000003 #
|
|
master-bin.000004 #
|
|
SHOW BINLOG EVENTS IN 'master-bin.000004' LIMIT 1,1;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
master-bin.000004 # Gtid_list # # [1-1-3,0-1-1,2-1-4]
|
|
SELECT * FROM t1 ORDER BY a;
|
|
a
|
|
1
|
|
2
|
|
3
|
|
*** Test crashing slave at various points and check that it recovers crash-safe. ***
|
|
include/stop_slave.inc
|
|
SET GLOBAL debug_dbug="+d,inject_crash_before_write_rpl_slave_state";
|
|
START SLAVE;
|
|
INSERT INTO t1 VALUES (4);
|
|
include/stop_slave.inc
|
|
SET GLOBAL debug_dbug="+d,crash_commit_before";
|
|
START SLAVE;
|
|
INSERT INTO t1 VALUES (5);
|
|
include/stop_slave.inc
|
|
SET GLOBAL debug_dbug="+d,crash_commit_after";
|
|
START SLAVE;
|
|
INSERT INTO t1 VALUES (6);
|
|
include/stop_slave.inc
|
|
SET GLOBAL debug_dbug="+d,inject_crash_before_flush_rli";
|
|
START SLAVE;
|
|
INSERT INTO t1 VALUES (7);
|
|
include/stop_slave.inc
|
|
SET GLOBAL debug_dbug="+d,inject_crash_after_flush_rli";
|
|
START SLAVE;
|
|
INSERT INTO t1 VALUES (8);
|
|
SELECT * FROM t1 ORDER BY a;
|
|
a
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
DROP TABLE t1;
|
|
include/rpl_end.inc
|