mirror of
https://github.com/MariaDB/server.git
synced 2025-01-27 17:33:44 +01:00
b7363eb4ac
Replace CHANGE MASTER TO ... master_gtid_pos='xxx' with a new system variable @@global.gtid_pos. This is more logical; @@gtid_pos is global, not per-master, and it is not affected by RESET SLAVE. Also rename master_gtid_pos=AUTO to master_use_gtid=1, which again is more logical.
273 lines
6.7 KiB
Text
273 lines
6.7 KiB
Text
--source include/have_innodb.inc
|
|
--source include/have_debug.inc
|
|
# Valgrind does not work well with test that crashes the server
|
|
--source include/not_valgrind.inc
|
|
|
|
--let $rpl_topology=1->2
|
|
--source include/rpl_init.inc
|
|
|
|
--echo *** Test crashing master, causing slave IO thread to reconnect while SQL thread is running ***
|
|
|
|
--connection server_1
|
|
call mtr.add_suppression("Checking table:");
|
|
call mtr.add_suppression("client is using or hasn't closed the table properly");
|
|
call mtr.add_suppression("Table .* is marked as crashed and should be repaired");
|
|
|
|
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);
|
|
--save_master_pos
|
|
|
|
--connection server_2
|
|
--sync_with_master
|
|
--source include/stop_slave.inc
|
|
--replace_result $MASTER_MYPORT MASTER_PORT
|
|
eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
|
|
MASTER_USE_GTID=1;
|
|
|
|
--connection server_1
|
|
INSERT INTO t1 VALUES (2,1);
|
|
INSERT INTO t1 VALUES (3,1);
|
|
|
|
--connection server_2
|
|
--source include/start_slave.inc
|
|
|
|
--connection server_1
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
|
wait-rpl_gtid_crash.test
|
|
EOF
|
|
|
|
let $1=200;
|
|
--disable_query_log
|
|
while ($1)
|
|
{
|
|
eval INSERT INTO t1 VALUES ($1 + 10, 2);
|
|
dec $1;
|
|
}
|
|
--enable_query_log
|
|
|
|
SET SESSION debug_dbug="+d,crash_dispatch_command_before";
|
|
--error 2006,2013
|
|
SELECT 1;
|
|
--source include/wait_until_disconnected.inc
|
|
|
|
--remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
|
restart-rpl_gtid_crash.test
|
|
EOF
|
|
|
|
--enable_reconnect
|
|
--source include/wait_until_connected_again.inc
|
|
|
|
--connection server_2
|
|
--let $wait_condition= SELECT COUNT(*) = 200 FROM t1 WHERE b=2
|
|
--source include/wait_condition.inc
|
|
|
|
--connection server_1
|
|
INSERT INTO t1 VALUES (1000, 3);
|
|
|
|
--connection server_2
|
|
--let $wait_condition= SELECT COUNT(*) = 1 FROM t1 WHERE b=3
|
|
--source include/wait_condition.inc
|
|
|
|
--connection server_1
|
|
DROP TABLE t1;
|
|
--save_master_pos
|
|
|
|
--echo *** Test crashing the master mysqld and check that binlog state is recovered. ***
|
|
--connection server_2
|
|
--sync_with_master
|
|
--source include/stop_slave.inc
|
|
RESET MASTER;
|
|
SET GLOBAL gtid_pos='';
|
|
|
|
--connection server_1
|
|
RESET MASTER;
|
|
--replace_column 2 # 4 # 5 #
|
|
SHOW BINLOG EVENTS IN 'master-bin.000001' LIMIT 1,1;
|
|
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
|
|
|
|
--connection server_2
|
|
--source include/start_slave.inc
|
|
|
|
--connection server_1
|
|
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;
|
|
--source include/show_binary_logs.inc
|
|
--replace_column 2 # 4 # 5 #
|
|
SHOW BINLOG EVENTS IN 'master-bin.000003' LIMIT 1,1;
|
|
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
|
wait
|
|
EOF
|
|
|
|
SET SESSION debug_dbug="+d,crash_dispatch_command_before";
|
|
--error 2006,2013
|
|
SELECT 1;
|
|
--source include/wait_until_disconnected.inc
|
|
|
|
--remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
|
restart
|
|
EOF
|
|
|
|
--enable_reconnect
|
|
--source include/wait_until_connected_again.inc
|
|
|
|
--source include/show_binary_logs.inc
|
|
--replace_column 2 # 4 # 5 #
|
|
SHOW BINLOG EVENTS IN 'master-bin.000004' LIMIT 1,1;
|
|
--save_master_pos
|
|
|
|
--connection server_2
|
|
--sync_with_master
|
|
SELECT * FROM t1 ORDER BY a;
|
|
|
|
|
|
--echo *** Test crashing slave at various points and check that it recovers crash-safe. ***
|
|
|
|
# Crash the slave just before updating mysql.rpl_slave_state table.
|
|
--source include/stop_slave.inc
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
|
|
wait
|
|
EOF
|
|
# We do not have to save @@GLOBAL.debug_dbug, it is reset when slave crashes.
|
|
SET GLOBAL debug_dbug="+d,inject_crash_before_write_rpl_slave_state";
|
|
START SLAVE;
|
|
|
|
--connection server_1
|
|
INSERT INTO t1 VALUES (4);
|
|
|
|
--connection server_2
|
|
--source include/wait_until_disconnected.inc
|
|
|
|
--remove_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
|
|
restart: --skip-slave-start=0
|
|
EOF
|
|
|
|
--enable_reconnect
|
|
--source include/wait_until_connected_again.inc
|
|
|
|
--let $wait_condition= SELECT COUNT(*) = 4 FROM t1
|
|
--source include/wait_condition.inc
|
|
|
|
# Crash the slave just before committing.
|
|
--source include/stop_slave.inc
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
|
|
wait
|
|
EOF
|
|
SET GLOBAL debug_dbug="+d,crash_commit_before";
|
|
START SLAVE;
|
|
|
|
--connection server_1
|
|
INSERT INTO t1 VALUES (5);
|
|
|
|
--connection server_2
|
|
--source include/wait_until_disconnected.inc
|
|
|
|
--remove_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
|
|
restart: --skip-slave-start=0
|
|
EOF
|
|
|
|
--enable_reconnect
|
|
--source include/wait_until_connected_again.inc
|
|
|
|
--let $wait_condition= SELECT COUNT(*) = 5 FROM t1
|
|
--source include/wait_condition.inc
|
|
|
|
# Crash the slave just after committing.
|
|
--source include/stop_slave.inc
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
|
|
wait
|
|
EOF
|
|
SET GLOBAL debug_dbug="+d,crash_commit_after";
|
|
START SLAVE;
|
|
|
|
--connection server_1
|
|
INSERT INTO t1 VALUES (6);
|
|
|
|
--connection server_2
|
|
--source include/wait_until_disconnected.inc
|
|
|
|
--remove_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
|
|
restart: --skip-slave-start=0
|
|
EOF
|
|
|
|
--enable_reconnect
|
|
--source include/wait_until_connected_again.inc
|
|
|
|
--let $wait_condition= SELECT COUNT(*) = 6 FROM t1
|
|
--source include/wait_condition.inc
|
|
|
|
# Crash the slave just before updating relay-log.info
|
|
--source include/stop_slave.inc
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
|
|
wait
|
|
EOF
|
|
SET GLOBAL debug_dbug="+d,inject_crash_before_flush_rli";
|
|
START SLAVE;
|
|
|
|
--connection server_1
|
|
INSERT INTO t1 VALUES (7);
|
|
|
|
--connection server_2
|
|
--source include/wait_until_disconnected.inc
|
|
|
|
--remove_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
|
|
restart: --skip-slave-start=0
|
|
EOF
|
|
|
|
--enable_reconnect
|
|
--source include/wait_until_connected_again.inc
|
|
|
|
--let $wait_condition= SELECT COUNT(*) = 7 FROM t1
|
|
--source include/wait_condition.inc
|
|
|
|
# Crash the slave just after updating relay-log.info
|
|
--source include/stop_slave.inc
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
|
|
wait
|
|
EOF
|
|
SET GLOBAL debug_dbug="+d,inject_crash_after_flush_rli";
|
|
START SLAVE;
|
|
|
|
--connection server_1
|
|
INSERT INTO t1 VALUES (8);
|
|
|
|
--connection server_2
|
|
--source include/wait_until_disconnected.inc
|
|
|
|
--remove_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
|
|
restart: --skip-slave-start=0
|
|
EOF
|
|
|
|
--enable_reconnect
|
|
--source include/wait_until_connected_again.inc
|
|
|
|
--let $wait_condition= SELECT COUNT(*) = 8 FROM t1
|
|
--source include/wait_condition.inc
|
|
|
|
|
|
# Check that everything was replicated correctly.
|
|
SELECT * FROM t1 ORDER BY a;
|
|
|
|
|
|
--connection server_1
|
|
DROP TABLE t1;
|
|
|
|
--connection default
|
|
--enable_reconnect
|
|
--source include/wait_until_connected_again.inc
|
|
|
|
--source include/rpl_end.inc
|