summaryrefslogtreecommitdiff
path: root/mysql-test/suite/rpl/t/rpl_init_slave_errors.test
blob: 180821730ecde9c1c9ca2662626a5dee2bee482e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
######################################################################
# Some errors that cause the slave SQL thread to stop are not shown in 
# the Slave_SQL_Error column of "SHOW SLAVE STATUS". Instead, the error 
# is only in the server's error log.
#
# Two failures and their respective reporting are verified:
#             
# 1 - Failures during slave thread initialization
# 2 - Failures while processing queries passed through the init_slave
# option.
#
# In order to check the first type of failure, we inject a fault in the 
# SQL/IO Threads through SET GLOBAL debug.
#
# To check the second type, we set @@global.init_slave to an invalid 
# command thus preventing the initialization of the SQL Thread.
#
# Obs:
# 1 - Note that testing failures while initializing the relay log position 
# is hard as the same function is called before the code reaches the point 
# that we want to test.
#
# 2 - This test does not target failures that are reported while applying 
# events such as duplicate keys, errors while reading the relay-log.bin*, 
# etc. Such errors are already checked on other tests.
######################################################################

######################################################################
#                    Configuring the Environment
######################################################################
source include/have_debug.inc;
source include/master-slave.inc;
source include/have_log_bin.inc;

connection slave;

--disable_warnings
stop slave;
--enable_warnings
reset slave;

######################################################################
#           Injecting faults in the threads' initialization
######################################################################
connection slave;

# Set debug flags on slave to force errors to occur
SET GLOBAL debug= "d,simulate_io_slave_error_on_init,simulate_sql_slave_error_on_init";

start slave;

#
# slave is going to stop because of emulated failures
# but there won't be any crashes nor asserts hit.
#
source include/wait_for_slave_to_stop.inc;

let $error= query_get_value(SHOW SLAVE STATUS, Last_Error, 1);
echo Reporting the following error: $error;
call mtr.add_suppression("Failed during slave I/O thread initialization");

SET GLOBAL debug= "";

######################################################################
#             Injecting faults in the init_slave option
######################################################################
connection slave;

--disable_warnings
stop slave;
--enable_warnings
source include/wait_for_slave_to_stop.inc;

reset slave;

SET GLOBAL init_slave= "garbage";

start slave;
source include/wait_for_slave_sql_to_stop.inc;

let $error= query_get_value(SHOW SLAVE STATUS, Last_Error, 1);
echo Reporting the following error: $error;

######################################################################
#                             Clean up
######################################################################
SET GLOBAL init_slave= "";