3 # Waits until SHOW SLAVE STATUS has returned a specified value, or
4 # until a timeout is reached.
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
19 # $slave_param, $slave_param_value
20 # This macro will wait until the column of the output of SHOW SLAVE
21 # STATUS named $slave_param gets the value $slave_param_value. See
24 # $slave_param_comparison
25 # By default, this file waits until $slave_param becomes equal to
26 # $slave_param_value. If you want to wait until $slave_param
27 # becomes *unequal* to $slave_param_value, set this parameter to the
28 # string '!=', like this:
29 # --let $slave_param_comparison= !=
32 # The default timeout is 60 seconds. You can change the timeout by
33 # setting $slave_timeout. The unit is one second.
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
48 --let $default_timeout= 30
50 --let $sleep_time= `select 1.0 / $sleep_freq`
52 --let $start_to_wait=`select current_timestamp()`
54 let $_slave_timeout= $slave_timeout;
57 let $_slave_timeout= `select $default_timeout * $sleep_freq`;
60 if ($slave_error_param ==
'')
62 --let $slave_error_param= 1
65 let $_slave_param_comparison= $slave_param_comparison;
66 if (!$_slave_param_comparison)
68 let $_slave_param_comparison= =;
73 --echo Waiting until
'$slave_param' $_slave_param_comparison
'$slave_param_value' [timeout=
'$_slave_timeout', \$slave_error_param=
'$slave_error_param']
76 --let $_slave_check_configured= query_get_value(
"SHOW SLAVE STATUS", Slave_IO_Running, 1)
78 if ($_slave_check_configured == 'No such row')
80 --echo **** ERROR: SHOW SLAVE
STATUS returned empty result
set. Slave not configured. ****
81 --source include/show_rpl_debug_info.inc
82 --die SHOW SLAVE
STATUS returned empty result
set. Slave not configured.
85 --let $_slave_timeout_counter= `select $_slave_timeout * $sleep_freq`
86 --let $_slave_continue= 1
87 while ($_slave_continue)
89 --let $_show_slave_status_value= query_get_value(
"SHOW SLAVE STATUS", $slave_param, 1)
91 # Check if an error condition is reached.
92 if (!$slave_error_param)
94 --let $_show_slave_status_error_value= query_get_value(
"SHOW SLAVE STATUS", $slave_error_param, 1)
95 if ($_show_slave_status_error_value)
97 --echo **** ERROR: $slave_error_param =
'$_show_slave_status_error_value' while waiting
for slave parameter $slave_param $_slave_param_comparison $slave_param_value ****
98 --source include/show_rpl_debug_info.inc
99 --die Error condition reached in include/wait_for_slave_param.inc
103 # Check if the termination condition is reached.
104 --let $_slave_continue= `SELECT NOT(
'$_show_slave_status_value' $_slave_param_comparison
'$slave_param_value')`
106 # Decrease timer, and check if the timeout is reached.
107 if ($_slave_continue)
109 --dec $_slave_timeout_counter
110 if (!$_slave_timeout_counter)
112 --let $end_to_wait=`select current_timestamp()`
114 --echo **** ERROR: timeout after $_slave_timeout ($end_to_wait - $start_to_wait) seconds while waiting for slave parameter $slave_param $_slave_param_comparison $slave_param_value ****
115 --source include/show_rpl_debug_info.inc
116 --die Timeout in include/wait_for_slave_param.inc
123 --let $include_filename= wait_for_slave_param.inc [$slave_param]
124 --source include/end_include_file.inc