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