3
3
# Waits until SHOW SLAVE STATUS has returned a specified value, or
4
4
# until a timeout is reached.
8
# let $slave_param= Slave_SQL_Running;
9
# let $slave_param_value= No;
10
# source include/slave_wait_param.inc;
9
# --let $slave_param= Slave_SQL_Running
10
# --let $slave_param_value= No
11
# [--let $slave_param_comparison= [ < | <= | >= | > | = | != ]]
12
# [--let $slave_timeout= NUMBER]
13
# [--let $slave_error_param= [Slave_SQL_Errno | Slave_IO_Errno]]
14
# [--let $rpl_debug= 1]
15
# --source include/slave_wait_param.inc
21
26
# $slave_param_value. If you want to wait until $slave_param
22
27
# becomes *unequal* to $slave_param_value, set this parameter to the
23
28
# string '!=', like this:
24
# let $slave_param_comparison= !=;
29
# --let $slave_param_comparison= !=
27
32
# The default timeout is 5 minutes. You can change the timeout by
28
# setting $slave_timeout. The unit is tenths of seconds.
31
# If the timeout is reached, debug info is given by calling SHOW
32
# SLAVE STATUS, SHOW PROCESSLIST, and SHOW BINLOG EVENTS. Then, a
33
# 'connection master' is then issued, and more debug info is given
34
# by calling SHOW MASTER STATUS, SHOW PROCESSLIST, and SHOW BINLOG
35
# EVENTS. If $master_connection is set, the latter three commands
36
# will be issued on $master_connection instead of on the host named
37
# 'master'. See also show_rpl_debug_info.inc
39
# $slave_error_message
40
# If set, this is printed when a timeout occurs. This is primarily
41
# intended to be used by other wait_for_slave_* macros, to indicate
42
# what the purpose of the wait was. (A very similar error message is
43
# given by default, but the wait_for_slave_* macros use this to give
44
# an error message identical to that in previous versions, so that
45
# errors are easier searchable in the pushbuild history.)
47
let $_slave_timeout_counter= $slave_timeout;
48
if (!$_slave_timeout_counter)
50
let $_slave_timeout_counter= 3000;
33
# setting $slave_timeout. The unit is seconds.
36
# If set, this script will check if the column of the output from
37
# SHOW SLAVE STATUS named $slave_error_param is nonzero. If it is,
38
# this script will faile immediately. Typically, this should be set
39
# to Last_IO_Errno or Last_SQL_Errno.
42
# See include/rpl_init.inc
45
--let $include_filename= wait_for_slave_param.inc [$slave_param]
46
--source include/begin_include_file.inc
49
let $_slave_timeout= $slave_timeout;
52
let $_slave_timeout= 300;
55
if (`SELECT '$slave_error_param' = ''`)
57
--let $slave_error_param= 1
53
60
let $_slave_param_comparison= $slave_param_comparison;
56
63
let $_slave_param_comparison= =;
59
let $_show_slave_status_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1);
60
while (`SELECT NOT('$_show_slave_status_value' $_slave_param_comparison '$slave_param_value') AND $_slave_timeout_counter > 0`)
62
dec $_slave_timeout_counter;
63
if ($_slave_timeout_counter)
66
let $_show_slave_status_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1);
70
# This has to be outside the loop until BUG#41913 has been fixed
71
if (!$_slave_timeout_counter)
73
--echo **** ERROR: timeout after $slave_timeout seconds while waiting for slave parameter $slave_param $_slave_param_comparison $slave_param_value ****
74
if ($slave_error_message)
76
--echo Message: $slave_error_message
78
--echo Current connection is '$CURRENT_CONNECTION'
79
echo Note: the following output may have changed since the failure was detected;
80
source include/show_rpl_debug_info.inc;
68
--echo Waiting until '$slave_param' $_slave_param_comparison '$slave_param_value' [timeout='$_slave_timeout', \$slave_error_param='$slave_error_param']
71
--let $_slave_check_configured= query_get_value("SHOW SLAVE STATUS", Slave_IO_Running, 1)
73
if (`SELECT '$_slave_check_configured' = 'No such row'`)
75
--echo **** ERROR: SHOW SLAVE STATUS returned empty result set. Slave not configured. ****
76
--source include/show_rpl_debug_info.inc
77
--die SHOW SLAVE STATUS returned empty result set. Slave not configured.
80
# mysqltest doesn't provide any better way to multiply by 10
81
--let $_wait_for_slave_param_zero= 0
82
--let $_slave_timeout_counter= $_slave_timeout$zero
83
--let $_slave_continue= 1
84
while ($_slave_continue)
86
--let $_show_slave_status_value= query_get_value("SHOW SLAVE STATUS", $slave_param, 1)
88
# Check if an error condition is reached.
89
if (!$slave_error_param)
91
--let $_show_slave_status_error_value= query_get_value("SHOW SLAVE STATUS", $slave_error_param, 1)
92
if ($_show_slave_status_error_value)
94
--echo **** ERROR: $slave_error_param = '$_show_slave_status_error_value' while waiting for slave parameter $slave_param $_slave_param_comparison $slave_param_value ****
95
--source include/show_rpl_debug_info.inc
96
--die Error condition reached in include/wait_for_slave_param.inc
100
# Check if the termination condition is reached.
101
--let $_slave_continue= `SELECT NOT('$_show_slave_status_value' $_slave_param_comparison '$slave_param_value')`
103
# Decrease timer, and check if the timeout is reached.
104
if ($_slave_continue)
106
--dec $_slave_timeout_counter
107
if (!$_slave_timeout_counter)
109
--echo **** ERROR: timeout after $_slave_timeout seconds while waiting for slave parameter $slave_param $_slave_param_comparison $slave_param_value ****
110
--source include/show_rpl_debug_info.inc
111
--die Timeout in include/wait_for_slave_param.inc
118
--let $include_filename= wait_for_slave_param.inc [$slave_param]
119
--source include/end_include_file.inc