mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
BUG#49978: Replication tests don't clean up replication state at the end
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.
This commit is contained in:
@ -3,11 +3,16 @@
|
||||
# Waits until SHOW SLAVE STATUS has returned a specified value, or
|
||||
# until a timeout is reached.
|
||||
#
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# let $slave_param= Slave_SQL_Running;
|
||||
# let $slave_param_value= No;
|
||||
# source include/slave_wait_param.inc;
|
||||
# --let $slave_param= Slave_SQL_Running
|
||||
# --let $slave_param_value= No
|
||||
# [--let $slave_param_comparison= [ < | <= | >= | > | = | != ]]
|
||||
# [--let $slave_timeout= NUMBER]
|
||||
# [--let $slave_error_param= [Slave_SQL_Errno | Slave_IO_Errno]]
|
||||
# [--let $rpl_debug= 1]
|
||||
# --source include/slave_wait_param.inc
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
@ -21,33 +26,35 @@
|
||||
# $slave_param_value. If you want to wait until $slave_param
|
||||
# becomes *unequal* to $slave_param_value, set this parameter to the
|
||||
# string '!=', like this:
|
||||
# let $slave_param_comparison= !=;
|
||||
# --let $slave_param_comparison= !=
|
||||
#
|
||||
# $slave_timeout
|
||||
# The default timeout is 5 minutes. You can change the timeout by
|
||||
# setting $slave_timeout. The unit is tenths of seconds.
|
||||
# setting $slave_timeout. The unit is seconds.
|
||||
#
|
||||
# $master_connection
|
||||
# If the timeout is reached, debug info is given by calling SHOW
|
||||
# SLAVE STATUS, SHOW PROCESSLIST, and SHOW BINLOG EVENTS. Then, a
|
||||
# 'connection master' is then issued, and more debug info is given
|
||||
# by calling SHOW MASTER STATUS, SHOW PROCESSLIST, and SHOW BINLOG
|
||||
# EVENTS. If $master_connection is set, the latter three commands
|
||||
# will be issued on $master_connection instead of on the host named
|
||||
# 'master'. See also show_rpl_debug_info.inc
|
||||
# $slave_error_param
|
||||
# If set, this script will check if the column of the output from
|
||||
# SHOW SLAVE STATUS named $slave_error_param is nonzero. If it is,
|
||||
# this script will faile immediately. Typically, this should be set
|
||||
# to Last_IO_Errno or Last_SQL_Errno.
|
||||
#
|
||||
# $slave_error_message
|
||||
# If set, this is printed when a timeout occurs. This is primarily
|
||||
# intended to be used by other wait_for_slave_* macros, to indicate
|
||||
# what the purpose of the wait was. (A very similar error message is
|
||||
# given by default, but the wait_for_slave_* macros use this to give
|
||||
# an error message identical to that in previous versions, so that
|
||||
# errors are easier searchable in the pushbuild history.)
|
||||
# $rpl_debug
|
||||
# See include/rpl_init.inc
|
||||
|
||||
let $_slave_timeout_counter= $slave_timeout;
|
||||
if (!$_slave_timeout_counter)
|
||||
|
||||
--let $include_filename= wait_for_slave_param.inc [$slave_param]
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
|
||||
let $_slave_timeout= $slave_timeout;
|
||||
if (!$_slave_timeout)
|
||||
{
|
||||
let $_slave_timeout_counter= 3000;
|
||||
let $_slave_timeout= 300;
|
||||
}
|
||||
|
||||
if (`SELECT '$slave_error_param' = ''`)
|
||||
{
|
||||
--let $slave_error_param= 1
|
||||
}
|
||||
|
||||
let $_slave_param_comparison= $slave_param_comparison;
|
||||
@ -56,27 +63,57 @@ if (!$_slave_param_comparison)
|
||||
let $_slave_param_comparison= =;
|
||||
}
|
||||
|
||||
let $_show_slave_status_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1);
|
||||
while (`SELECT NOT('$_show_slave_status_value' $_slave_param_comparison '$slave_param_value') AND $_slave_timeout_counter > 0`)
|
||||
if ($rpl_debug)
|
||||
{
|
||||
dec $_slave_timeout_counter;
|
||||
if ($_slave_timeout_counter)
|
||||
--echo Waiting until '$slave_param' $_slave_param_comparison '$slave_param_value' [timeout='$_slave_timeout', \$slave_error_param='$slave_error_param']
|
||||
}
|
||||
|
||||
--let $_slave_check_configured= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, 1)
|
||||
|
||||
if (`SELECT '$_slave_check_configured' = 'No such row'`)
|
||||
{
|
||||
--echo **** ERROR: SHOW SLAVE STATUS returned empty result set. Slave not configured. ****
|
||||
--source include/show_rpl_debug_info.inc
|
||||
--die SHOW SLAVE STATUS returned empty result set. Slave not configured.
|
||||
}
|
||||
|
||||
# mysqltest doesn't provide any better way to multiply by 10
|
||||
--let $_wait_for_slave_param_zero= 0
|
||||
--let $_slave_timeout_counter= $_slave_timeout$zero
|
||||
--let $_slave_continue= 1
|
||||
while ($_slave_continue)
|
||||
{
|
||||
--let $_show_slave_status_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1)
|
||||
|
||||
# Check if an error condition is reached.
|
||||
if (!$slave_error_param)
|
||||
{
|
||||
sleep 0.1;
|
||||
let $_show_slave_status_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1);
|
||||
--let $_show_slave_status_error_value= query_get_value("SHOW SLAVE STATUS", $slave_error_param, 1)
|
||||
if ($_show_slave_status_error_value)
|
||||
{
|
||||
--echo **** ERROR: $slave_error_param = '$_show_slave_status_error_value' while waiting for slave parameter $slave_param $_slave_param_comparison $slave_param_value ****
|
||||
--source include/show_rpl_debug_info.inc
|
||||
--die Error condition reached in include/wait_for_slave_param.inc
|
||||
}
|
||||
}
|
||||
|
||||
# Check if the termination condition is reached.
|
||||
--let $_slave_continue= `SELECT NOT('$_show_slave_status_value' $_slave_param_comparison '$slave_param_value')`
|
||||
|
||||
# Decrease timer, and check if the timeout is reached.
|
||||
if ($_slave_continue)
|
||||
{
|
||||
--dec $_slave_timeout_counter
|
||||
if (!$_slave_timeout_counter)
|
||||
{
|
||||
--echo **** ERROR: timeout after $_slave_timeout seconds while waiting for slave parameter $slave_param $_slave_param_comparison $slave_param_value ****
|
||||
--source include/show_rpl_debug_info.inc
|
||||
--die Timeout in include/wait_for_slave_param.inc
|
||||
}
|
||||
--sleep 0.1
|
||||
}
|
||||
}
|
||||
|
||||
# This has to be outside the loop until BUG#41913 has been fixed
|
||||
if (!$_slave_timeout_counter)
|
||||
{
|
||||
--echo **** ERROR: timeout after $slave_timeout seconds while waiting for slave parameter $slave_param $_slave_param_comparison $slave_param_value ****
|
||||
if ($slave_error_message)
|
||||
{
|
||||
--echo Message: $slave_error_message
|
||||
}
|
||||
--echo Current connection is '$CURRENT_CONNECTION'
|
||||
echo Note: the following output may have changed since the failure was detected;
|
||||
source include/show_rpl_debug_info.inc;
|
||||
die;
|
||||
}
|
||||
|
||||
--let $include_filename= wait_for_slave_param.inc [$slave_param]
|
||||
--source include/end_include_file.inc
|
||||
|
Reference in New Issue
Block a user