mirror of
https://github.com/MariaDB/server.git
synced 2025-08-26 01:44:06 +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.
100 lines
2.9 KiB
Plaintext
100 lines
2.9 KiB
Plaintext
# ==== Purpose ====
|
|
#
|
|
# Tests that an autocommitted XA transaction where the master crashes
|
|
# just before writing the XID log event is executed correctly. The
|
|
# master rolls back, so the slave should not execute statement.
|
|
#
|
|
# This test was previously part of rpl_ndb_transaction.test
|
|
#
|
|
#
|
|
# ==== Method ====
|
|
#
|
|
# We want master to be alive so that it can replicate the statement to
|
|
# the slave. So in the test case, we must not crash the
|
|
# master. Instead, we fake the crash by just not writing the XID event
|
|
# to the binlog. This is done by the @@debug='d,do_not_write_xid'
|
|
# flag. This, in turn, requires us to do 'source
|
|
# include/have_debug.inc'
|
|
#
|
|
# So, unlike if the master had crashed, the master *will* execute the
|
|
# statement. But the slave should not execute it. Hence, after the
|
|
# test is executed, the expected result on master is a table with one
|
|
# row, and on slave a table with no rows.
|
|
#
|
|
# To simulate the slave correctly, we wait until everything up to but
|
|
# not including the XID is replicated. This has to be done with
|
|
# include/sync_slave_io_with_master.inc, not sync_slave_with_master,
|
|
# since the latter waits until the slave *SQL* thread has caught up
|
|
# with the master's position, which it will never do.
|
|
#
|
|
#
|
|
# ==== Related bugs ====
|
|
#
|
|
# BUG#26395: if crash during autocommit update to transactional table on master, slave fails
|
|
|
|
source include/have_innodb.inc;
|
|
# have_debug is needed since we use the @@debug variable on master
|
|
source include/have_debug.inc;
|
|
source include/master-slave.inc;
|
|
|
|
|
|
--echo ==== Initialize ====
|
|
|
|
--echo [on master]
|
|
--connection master
|
|
|
|
CREATE TABLE tinnodb (a INT) ENGINE = INNODB;
|
|
SHOW CREATE TABLE tinnodb;
|
|
|
|
# do_not_write_xid stops the master from writing an XID event.
|
|
set @old_debug= @@debug;
|
|
set @@debug= 'd,do_not_write_xid';
|
|
|
|
|
|
--echo ==== Test ====
|
|
|
|
# Save the position up to which the slave SQL thread should execute.
|
|
save_master_pos;
|
|
|
|
# Execute query and check that the row made it to the table.
|
|
INSERT INTO tinnodb VALUES (1);
|
|
SELECT * FROM tinnodb ORDER BY a;
|
|
|
|
# Sync slave's IO thread.
|
|
--echo [on slave]
|
|
source include/sync_slave_io_with_master.inc;
|
|
|
|
# Sync slave's SQL thread.
|
|
sync_with_master 0;
|
|
|
|
|
|
--echo ==== Verify results on slave ====
|
|
|
|
source include/stop_slave.inc;
|
|
let $tmp= query_get_value("SHOW SLAVE STATUS", Slave_IO_State, 1);
|
|
eval SELECT "$tmp" AS Slave_IO_State;
|
|
let $tmp= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
|
|
eval SELECT "$tmp" AS Last_SQL_Error;
|
|
let $tmp= query_get_value("SHOW SLAVE STATUS", Last_IO_Error, 1);
|
|
eval SELECT "$tmp" AS Last_IO_Error;
|
|
SELECT * FROM tinnodb ORDER BY a;
|
|
|
|
|
|
--echo ==== Clean up ====
|
|
|
|
# Easiest to clean up master and slave separately, without
|
|
# replication, since master and slave are out of sync.
|
|
|
|
--echo [on master]
|
|
connection master;
|
|
DROP TABLE tinnodb;
|
|
set @@debug= @old_debug;
|
|
|
|
--echo [on slave]
|
|
connection slave;
|
|
DROP TABLE tinnodb;
|
|
|
|
# Warning: do not add more tests here. The binlog is in a bad state.
|
|
--let $rpl_only_running_threads= 1
|
|
--source include/rpl_end.inc
|