1# ==== Purpose ====
2#
3# Waits until the IO thread of the current connection has got an
4# error, or until a timeout is reached. Also waits until the IO
5# thread has completely stopped.
6#
7#
8# ==== Usage ====
9#
10# --let $slave_io_errno= NUMBER [, NUMBER ...]
11# [--let $show_slave_io_error= 1]
12# [--let $slave_io_error_is_nonfatal= 1]
13# [--let $rpl_debug= 1]
14# [--let $slave_timeout= NUMBER]
15# --source include/wait_for_slave_io_error.inc
16#
17# Parameters:
18#   $slave_io_errno
19#     The expected IO error numbers. This can be either a single
20#     number, or a comma-separated list of numbers. Examples:
21#       --let $slave_io_errno= 1053, 2002, 2003, 2006, 2013
22#       --let $slave_io_errno= 1045
23#     (After BUG#41956 has been fixed, this will be required to be
24#     symbolic names instead of numbers.)
25#
26#   $show_slave_io_error
27#     If set, will print the error to the query log.
28#
29#   $slave_io_error_is_nonfatal
30#     By default, we wait for the slave IO thread to stop completely
31#     (i.e., until Slave_IO_State is empty).  If this variable is set,
32#     then we don't wait. This is useful if the error is non-fatal
33#     (e.g., temporary connection error) and does not cause the slave
34#     IO thread to stop.
35#
36#   $slave_io_error_replace
37#     If set, one or more regex patterns for replacing variable
38#     text in the error message. Syntax as --replace-regex
39#
40#   $slave_timeout
41#     See include/wait_for_slave_param.inc
42#
43#   $rpl_debug
44#     See include/rpl_init.inc
45
46
47--let $include_filename= wait_for_slave_io_error.inc [errno=$slave_io_errno]
48--source include/begin_include_file.inc
49
50
51let $old_slave_param_comparison= $slave_param_comparison;
52let $slave_param= Last_IO_Errno;
53let $slave_param_comparison= !=;
54let $slave_param_value= 0;
55source include/wait_for_slave_param.inc;
56let $slave_param_comparison= $old_slave_param_comparison;
57
58let $_wfsie_errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1);
59
60if ($slave_io_errno == '') {
61  --echo !!!ERROR IN TEST: you must set \$slave_io_errno before you source
62  --echo !!!wait_for_slave_sql_error.inc. The error we got this time was '$_wfsie_errno',
63  --echo !!!so you probably want to add the following line to your test case:
64  --echo !!!  --let \$slave_io_errno= $_wfsie_errno
65  --die !!!ERROR IN TEST: you must set \$slave_io_errno before sourcing wait_for_slave_io_error.inc
66}
67
68if (`SELECT $_wfsie_errno NOT IN ($slave_io_errno)`) {
69  --echo **** Slave stopped with wrong error code: $_wfsie_errno (expected $slave_io_errno) ****
70  source include/show_rpl_debug_info.inc;
71  --echo **** Slave stopped with wrong error code: $_wfsie_errno (expected $slave_io_errno) ****
72  --die Slave stopped with wrong error code
73}
74
75if ($show_slave_io_error)
76{
77  --let $_wait_for_slave_io_error_old_status_items= $status_items
78  --let $status_items= Last_IO_Error
79  --let $slave_field_result_replace= $slave_io_error_replace
80  --source include/show_slave_status.inc
81  --let $status_items= $_wait_for_slave_io_error_old_status_items
82}
83
84if (!$slave_io_error_is_nonfatal)
85{
86  --let $slave_param= Slave_IO_State
87  --let $slave_param_value=
88  --source include/wait_for_slave_param.inc
89}
90--let $slave_io_error_is_nonfatal= 0
91
92
93--let $include_filename= wait_for_slave_io_error.inc [errno=$slave_io_errno]
94--source include/end_include_file.inc
95