mirror of
https://github.com/MariaDB/server.git
synced 2025-02-04 21:02:17 +01:00
5ab5ff08b0
This commit makes replicas crash-safe by default by changing the Using_Gtid value to be Slave_Pos on a fresh slave start and after RESET SLAVE is issued. If the primary server does not support GTIDs (i.e., version < 10), the replica will fall back to Using_Gtid=No on slave start and after RESET SLAVE. The following additional informational messages/warnings are added: 1. When Using_Gtid is automatically changed. That is, if RESET SLAVE reverts Using_Gtid back to Slave_Pos, or Using_Gtid is inferred to No from a CHANGE MASTER TO given with log coordinates without MASTER_USE_GTID. 2. If options are ignored in CHANGE MASTER TO. If CHANGE MASTER TO is given with log coordinates, yet also specifies MASTER_USE_GTID=Slave_Pos, a warning message is given that the log coordinate options are ignored. Additionally, an MTR macro has been added for RESET SLAVE, reset_slave.inc, which provides modes/options for resetting a slave in log coordinate or gtid modes. When in log coordinates mode, the macro will execute CHANGE MASTER TO MASTER_USE_GTID=No after the RESET SLAVE command. When in GTID mode, an extra parameter, reset_slave_keep_gtid_state, can be set to reset or preserve the value of gtid_slave_pos. Reviewed By: =========== Andrei Elkin <andrei.elkin@mariadb.com>
118 lines
3.3 KiB
Text
118 lines
3.3 KiB
Text
# Requires binlog_format=statement format since query involving
|
|
# get_lock() is logged in row format if binlog_format=mixed or row.
|
|
-- source include/have_binlog_format_statement.inc
|
|
-- source include/master-slave.inc
|
|
|
|
CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
|
|
|
|
# Load some data into t1
|
|
create table t1 (word char(20) not null);
|
|
load data infile '../../std_data/words.dat' into table t1;
|
|
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
|
|
eval load data local infile '$MYSQL_TEST_DIR/std_data/words.dat' into table t1;
|
|
select * from t1 limit 10;
|
|
|
|
#
|
|
# Test slave with wrong password
|
|
#
|
|
sync_slave_with_master;
|
|
stop slave;
|
|
connection master;
|
|
create temporary table tmp select * from mysql.global_priv where host="localhost" and user="root";
|
|
set password for root@"localhost" = password('foo');
|
|
connection slave;
|
|
start slave;
|
|
connection master;
|
|
#
|
|
# Give slave time to do at last one failed connect retry
|
|
# This one must be short so that the slave will not stop retrying
|
|
real_sleep 2;
|
|
replace into mysql.global_priv select * from tmp;
|
|
drop temporary table tmp;
|
|
flush privileges;
|
|
# Give slave time to connect (will retry every second)
|
|
sleep 2;
|
|
|
|
create table t3(n int);
|
|
insert into t3 values(1),(2);
|
|
sync_slave_with_master;
|
|
select * from t3;
|
|
select sum(length(word)) from t1;
|
|
connection master;
|
|
drop table t1,t3;
|
|
sync_slave_with_master;
|
|
|
|
# Test if the slave SQL thread can be more than 16K behind the slave
|
|
# I/O thread (> IO_SIZE)
|
|
|
|
connection master;
|
|
# we'll use table-level locking to delay slave SQL thread
|
|
eval create table t1 (n int);
|
|
sync_slave_with_master;
|
|
connection master;
|
|
reset master;
|
|
connection slave;
|
|
stop slave;
|
|
--source include/reset_slave.inc
|
|
|
|
connection master;
|
|
let $1=5000;
|
|
# Generate 16K of relay log
|
|
disable_query_log;
|
|
while ($1)
|
|
{
|
|
eval insert into t1 values($1);
|
|
dec $1;
|
|
}
|
|
enable_query_log;
|
|
|
|
# Try to cause a large relay log lag on the slave by locking t1
|
|
connection slave;
|
|
lock tables t1 read;
|
|
start slave;
|
|
connection master;
|
|
--source include/sync_slave_io_with_master.inc
|
|
unlock tables;
|
|
|
|
#test handling of aborted connection in the middle of update
|
|
|
|
connection master;
|
|
create table t2(id int);
|
|
insert into t2 values(connection_id());
|
|
|
|
connection master1;
|
|
# Avoid generating result
|
|
create temporary table t3(n int);
|
|
--disable_warnings
|
|
insert into t3 select get_lock('crash_lock%20C', 1) from t2;
|
|
--enable_warnings
|
|
|
|
connection master;
|
|
send update t1 set n = n + get_lock('crash_lock%20C', 2);
|
|
connection master1;
|
|
let $wait_condition= SELECT count(*) > 0 FROM information_schema.processlist WHERE info LIKE 'update%' AND state='User lock';
|
|
source include/wait_condition.inc;
|
|
select (@id := id) - id from t2;
|
|
kill @id;
|
|
drop table t2;
|
|
drop temporary table t3;
|
|
connection master;
|
|
# The get_lock function causes warning for unsafe statement.
|
|
--disable_warnings
|
|
# 2013 = CR_SERVER_LOST
|
|
--error ER_QUERY_INTERRUPTED,ER_CONNECTION_KILLED,2013
|
|
reap;
|
|
--enable_warnings
|
|
connection slave;
|
|
# The SQL slave thread should now have stopped because the query was killed on
|
|
# the master (so it has a non-zero error code in the binlog).
|
|
# 1927 = ER_CONNECTION_KILLED
|
|
--let $slave_sql_errno= 1927
|
|
--source include/wait_for_slave_sql_error_and_skip.inc
|
|
|
|
select count(*) from t1;
|
|
connection master1;
|
|
drop table t1;
|
|
|
|
# End of 4.1 tests
|
|
--source include/rpl_end.inc
|