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 ...] [# comment]
11# [--let $show_slave_io_error= 1]
12# [--let $slave_io_error_is_nonfatal= 1]
13# [--let $slave_io_error_replace= REGEX]
14# [--let $rpl_debug= 1]
15# [--let $slave_timeout= NUMBER]
16# --source include/wait_for_slave_io_error.inc
17#
18# Parameters:
19#   $slave_io_errno
20#     The expected IO error numbers. This can be either a single
21#     number, or a comma-separated list of numbers. Examples:
22#       --let $slave_io_errno= 1040, 1053, 2002, 2003, 2006, 2013
23#       --let $slave_io_errno= 1593 # ER_SLAVE_FATAL_ERROR
24#     It is allowed to add a comment at the end of the line, and it
25#     is strongly advised to put the symbolic name of the error in
26#     this comment, like the example above.
27#     (After BUG#41956 has been fixed, this will be required to be
28#     symbolic names instead of numbers.)
29#
30#   $show_slave_io_error
31#     If set, will print the error to the query log.
32#
33#   $slave_io_error_is_nonfatal
34#     By default, we wait for the slave IO thread to stop completely
35#     (i.e., until Slave_IO_State is empty).  If this variable is set,
36#     then we don't wait. This is useful if the error is non-fatal
37#     (e.g., temporary connection error) and does not cause the slave
38#     IO thread to stop.
39#
40#   $slave_io_error_replace
41#     If set, one or more regex patterns for replacing variable
42#     text in the error message. Syntax as --replace-regex
43#
44#   $slave_timeout
45#     See include/wait_for_slave_param.inc
46#
47#   $rpl_debug
48#     See include/rpl_init.inc
49
50
51--let $include_filename= wait_for_slave_io_error.inc [errno=$slave_io_errno]
52--source include/begin_include_file.inc
53
54
55let $old_slave_param_comparison= $slave_param_comparison;
56let $slave_param= Last_IO_Errno;
57let $slave_param_comparison= !=;
58let $slave_param_value= 0;
59source include/wait_for_slave_param.inc;
60let $slave_param_comparison= $old_slave_param_comparison;
61
62let $_wfsie_errno= query_get_value(SHOW SLAVE STATUS, Last_IO_Errno, 1);
63
64if ($slave_io_errno == '')
65{
66  --echo !!!ERROR IN TEST: you must set \$slave_io_errno before you source
67  --echo !!!wait_for_slave_io_error.inc. The error we got this time was '$_wfsie_errno',
68  --echo !!!so you probably want to add the following line to your test case:
69  --echo !!!  --let \$slave_io_errno= $_wfsie_errno
70  query_vertical SHOW SLAVE STATUS;
71  --die !!!ERROR IN TEST: you must set \$slave_io_errno before sourcing wait_for_slave_io_error.inc
72}
73
74# Strip away comments
75--let $_slave_io_errno= `SELECT IF(LOCATE('#', '$slave_io_errno') != 0, SUBSTR('$slave_io_errno', 1, LOCATE('#', '$slave_io_errno') - 1), '$slave_io_errno')`
76if ($rpl_debug)
77{
78  --echo # debug: slave_io_errno='$slave_io_errno'; stripped from comments='$_slave_io_errno' wfsie_errno='$_wfsie_errno'
79}
80
81if (`SELECT $_wfsie_errno NOT IN ($_slave_io_errno)`)
82{
83  --echo **** Slave stopped with wrong error code: $_wfsie_errno (expected $slave_io_errno) ****
84  source include/show_rpl_debug_info.inc;
85  --echo **** Slave stopped with wrong error code: $_wfsie_errno (expected $slave_io_errno) ****
86  --die Slave stopped with wrong error code
87}
88
89if ($show_slave_io_error)
90{
91  --let $_wait_for_slave_io_error_old_status_items= $status_items
92  --let $status_items= Last_IO_Error
93  --let $slave_field_result_replace= $slave_io_error_replace
94  --source include/show_slave_status.inc
95  --let $status_items= $_wait_for_slave_io_error_old_status_items
96}
97
98if (!$slave_io_error_is_nonfatal)
99{
100  --let $slave_param= Slave_IO_State
101  --let $slave_param_value=
102  --source include/wait_for_slave_param.inc
103}
104--let $slave_io_error_is_nonfatal= 0
105
106
107--let $include_filename= wait_for_slave_io_error.inc [errno=$slave_io_errno]
108--source include/end_include_file.inc
109