mirror of
https://github.com/MariaDB/server.git
synced 2025-08-27 13:04:36 +03:00
Major replication test framework cleanup. This does the following: - Ensure that all tests clean up the replication state when they finish, by making check-testcase check the output of SHOW SLAVE STATUS. This implies: - Slave must not be running after test finished. This is good because it removes the risk for sporadic errors in subsequent tests when a test forgets to sync correctly. - Slave SQL and IO errors must be cleared when test ends. This is good because we will notice if a test gets an unexpected error in the slave threads near the end. - We no longer have to clean up before a test starts. - Ensure that all tests that wait for an error in one of the slave threads waits for a specific error. It is no longer possible to source wait_for_slave_[sql|io]_to_stop.inc when there is an error in one of the slave threads. This is good because: - If a test expects an error but there is a bug that causes another error to happen, or if it stops the slave thread without an error, then we will notice. - When developing tests, wait_for_*_to_[start|stop].inc will fail immediately if there is an error in the relevant slave thread. Before this patch, we had to wait for the timeout. - Remove duplicated and repeated code for setting up unusual replication topologies. Now, there is a single file that is capable of setting up arbitrary topologies (include/rpl_init.inc, but include/master-slave.inc is still available for the most common topology). Tests can now end with include/rpl_end.inc, which will clean up correctly no matter what topology is used. The topology can be changed with include/rpl_change_topology.inc. - Improved debug information when tests fail. This includes: - debug info is printed on all servers configured by include/rpl_init.inc - User can set $rpl_debug=1, which makes auxiliary replication files print relevant debug info. - Improved documentation for all auxiliary replication files. Now they describe purpose, usage, parameters, and side effects. - Many small code cleanups: - Made have_innodb.inc output a sensible error message. - Moved contents of rpl000017-slave.sh into rpl000017.test - Added mysqltest variables that expose the current state of disable_warnings/enable_warnings and friends. - Too many to list here: see per-file comments for details.
167 lines
4.4 KiB
Plaintext
167 lines
4.4 KiB
Plaintext
#
|
|
# Bug #38205 Row-based Replication (RBR) causes inconsistencies: HA_ERR_FOUND_DUPP_KEY
|
|
# Bug#319 if while a non-transactional slave is replicating a transaction possible problem
|
|
#
|
|
# Verifying the fact that STOP SLAVE in the middle of a group execution waits
|
|
# for the end of the group before the slave sql thread will stop.
|
|
# The patch refines STOP SLAVE to not interrupt a transaction or other type of
|
|
# the replication events group (the part I).
|
|
# Killing the sql thread continues to provide a "hard" stop (the part II).
|
|
#
|
|
# Non-deterministic tests
|
|
#
|
|
|
|
source include/master-slave.inc;
|
|
source include/have_innodb.inc;
|
|
|
|
|
|
#
|
|
# Part II, killed sql slave leaves instantly
|
|
#
|
|
|
|
# A. multi-statement transaction as the replication group
|
|
|
|
connection master;
|
|
|
|
create table t1i(n int primary key) engine=innodb;
|
|
create table t2m(n int primary key) engine=myisam;
|
|
|
|
sync_slave_with_master;
|
|
|
|
connection master;
|
|
|
|
begin;
|
|
insert into t1i values (1);
|
|
insert into t1i values (2);
|
|
insert into t1i values (3);
|
|
commit;
|
|
|
|
sync_slave_with_master;
|
|
|
|
#
|
|
# todo: first challenge is to find out the SQL thread id
|
|
# the following is not fully reliable
|
|
#
|
|
|
|
let $id=`SELECT id from information_schema.processlist where user like 'system user' and state like '%Has read all relay log%' or user like 'system user' and state like '%Reading event from the relay log%'`;
|
|
connection slave;
|
|
begin;
|
|
insert into t1i values (5);
|
|
|
|
connection master;
|
|
let $pos0_master= query_get_value(SHOW MASTER STATUS, Position, 1);
|
|
begin;
|
|
insert into t1i values (4);
|
|
insert into t2m values (1); # non-ta update
|
|
update t1i set n = 5 where n = 4; # to block at. can't be played with killed
|
|
commit;
|
|
let $pos1_master= query_get_value(SHOW MASTER STATUS, Position, 1);
|
|
|
|
connection slave;
|
|
# slave sql thread must be locked out by the conn `slave' explicit lock
|
|
let $pos0_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
|
|
--disable_query_log
|
|
eval select $pos0_master - $pos0_slave as zero;
|
|
--enable_query_log
|
|
|
|
connection slave1;
|
|
|
|
let $count= 1;
|
|
let $table= t2m;
|
|
source include/wait_until_rows_count.inc;
|
|
#
|
|
# todo: may fail as said above
|
|
#
|
|
--echo *** kill sql thread ***
|
|
--disable_query_log
|
|
eval kill connection $id;
|
|
--enable_query_log
|
|
|
|
connection slave;
|
|
rollback; # release the sql thread
|
|
|
|
connection slave1;
|
|
|
|
source include/wait_for_slave_sql_to_stop.inc;
|
|
let $sql_status= query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1);
|
|
--echo *** sql thread is *not* running: $sql_status ***
|
|
let $pos1_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
|
|
|
|
connection slave;
|
|
--echo *** the prove: the killed slave has not finished the current transaction ***
|
|
|
|
--disable_query_log
|
|
select count(*) as three from t1i;
|
|
eval select $pos1_master > $pos1_slave as one;
|
|
eval select $pos1_slave - $pos0_slave as zero;
|
|
--enable_query_log
|
|
|
|
delete from t2m; # remove the row to be able to replay
|
|
start slave sql_thread;
|
|
|
|
#
|
|
# Part I: B The homogenous transaction remains interuptable in between
|
|
#
|
|
|
|
connection master;
|
|
delete from t1i;
|
|
delete from t2m;
|
|
|
|
sync_slave_with_master;
|
|
begin;
|
|
insert into t1i values (5);
|
|
|
|
connection master;
|
|
let $pos0_master= query_get_value(SHOW MASTER STATUS, Position, 1);
|
|
begin;
|
|
insert into t1i values (4);
|
|
update t1i set n = 5 where n = 4; # to block at. not to be played
|
|
commit;
|
|
let $pos1_master= query_get_value(SHOW MASTER STATUS, Position, 1);
|
|
|
|
|
|
connection slave1;
|
|
# slave sql can't advance as must be locked by the conn `slave' trans
|
|
let $pos0_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
|
|
--disable_query_log
|
|
eval select $pos0_master - $pos0_slave as zero;
|
|
--enable_query_log
|
|
|
|
#
|
|
# the replicated trans is blocked by the slave's local.
|
|
# However, it's not easy to catch the exact moment when it happens.
|
|
# The test issues sleep which makes the test either non-deterministic or
|
|
# wasting too much time.
|
|
#
|
|
--sleep 3
|
|
|
|
send stop slave sql_thread;
|
|
|
|
connection slave;
|
|
rollback; # release the sql thread
|
|
|
|
connection slave1;
|
|
reap;
|
|
source include/wait_for_slave_sql_to_stop.inc;
|
|
let $sql_status= query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1);
|
|
--echo *** sql thread is *not* running: $sql_status ***
|
|
|
|
let $pos1_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
|
|
|
|
--echo *** the prove: the stopped slave has rolled back the current transaction ***
|
|
|
|
--disable_query_log
|
|
select count(*) as zero from t1i;
|
|
eval select $pos0_master - $pos0_slave as zero;
|
|
eval select $pos1_master > $pos0_slave as one;
|
|
--enable_query_log
|
|
|
|
start slave sql_thread;
|
|
|
|
# clean-up
|
|
|
|
connection master;
|
|
drop table t1i, t2m;
|
|
|
|
--source include/rpl_end.inc
|