Debian Codegraph @

mysql-test/suite/rpl/t/rpl_io_thd_wait_for_disk_space.test

raw
1 # ==== Purpose ====
2 #
3 # Check that the execution of SHOW SLAVE STATUS command is not blocked when IO
4 # thread is blocked waiting for disk space.
5 #
6 # ==== Implementation ====
7 #
8 # There are two steps on this test case:
9 #
10 # 1st Step
11 #
12 # Simulate a scenario where IO thread is waiting for disk space while writing
13 # into the relay log. Execute SHOW SLAVE STATUS command after IO thread is
14 # blocked waiting for space. The command should not be blocked.
15 #
16 # 2nd Step
17 #
18 # The slave server should respond promptly when asked to shutdown. No warnings
19 # about the "STOP SLAVE" waiting for disk space should be generated.
20 #
21 # ==== References ====
22 #
23 # WL#10406: Improve usability when receiver thread is waiting for disk space
24 # Bug#21753696: MAKE SHOW SLAVE STATUS NON BLOCKING IF IO THREAD WAITS FOR
25 # DISK SPACE
26 #
27 ###############################################################################
28 --source include/have_debug.inc
29 --source include/master-slave.inc
30
31 # Generate events to be replicated to the slave
32 CREATE TABLE t1(a INT);
33 INSERT INTO t1 VALUES(1);
34 --source include/sync_slave_sql_with_master.inc
35
36 # Those errors will only happen in the slave
37 CALL mtr.add_suppression("Disk is full writing");
38 CALL mtr.add_suppression("Retry in 60 secs");
39 CALL mtr.add_suppression("Relay log write failure");
40 CALL mtr.add_suppression("Recovery from source pos");
41 CALL mtr.add_suppression("Relay log recovery on channel with GTID_ONLY=1*");
42 CALL mtr.add_suppression("Waiting until I/O thread .* finish writing to disk before stopping");
43
44 --echo #
45 --echo # Step 1 - Monitor and kill I/O thread while waiting for disk space
46 --echo #
47
48 --let $io_id=`SELECT PROCESSLIST_ID FROM performance_schema.threads WHERE NAME = 'thread/sql/replica_io'`
49
50 # Set the debug option that will simulate disk full
51 --let $debug_point=simulate_io_thd_wait_for_disk_space
52 --source include/add_debug_point.inc
53
54 # Generate events to be replicated to the slave
55 --source include/rpl_connection_master.inc
56 INSERT INTO t1 VALUES(2);
57
58 --source include/rpl_connection_slave.inc
59 # Wait until IO thread is waiting for disk space
60 # Notice that this is performed by querying SHOW SLAVE STATUS
61 --let $slave_param= Slave_IO_State
62 --let $slave_param_value= Waiting for disk space
63 --source include/wait_for_slave_param.inc
64
65 # performance_schema.threads and information_schema.processlist checks
66 --let $io_state=`SELECT PROCESSLIST_STATE FROM performance_schema.threads WHERE NAME = 'thread/sql/replica_io'`
67 --let $assert_text= I/O thread PROCESSLIST_STATE should be Waiting for disk space at performance_schema.threads
68 --let $assert_cond= "$io_state" = "Waiting for disk space"
69 --source include/assert.inc
70
71 --let $io_state=`SELECT STATE FROM information_schema.processlist WHERE ID = $io_id`
72 --let $assert_text= I/O thread STATE should be Waiting for disk space at information_schema.processlist
73 --let $assert_cond= "$io_state" = "Waiting for disk space"
74 --source include/assert.inc
75
76 # Get the relay log file name, also using SHOW SLAVE STATUS
77 --let $relay_log_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)
78
79 # STOP SLAVE IO_THREAD should be blocked
80 --source include/rpl_connection_slave1.inc
81 --send STOP SLAVE IO_THREAD
82
83 # But the KILL on it should unblock it
84 --source include/rpl_connection_slave.inc
85 SET DEBUG_SYNC="now WAIT_FOR reached_stopping_io_thread";
86 --replace_result $io_id IO_THREAD
87 --eval KILL $io_id
88
89 --source include/rpl_connection_slave1.inc
90 --reap
91
92 --source include/rpl_connection_slave.inc
93 --let $slave_io_errno= convert_error(ER_REPLICA_RELAY_LOG_WRITE_FAILURE)
94 --source include/wait_for_slave_io_error.inc
95
96 # Restore the debug options to "simulate" freed space on disk
97 --source include/remove_debug_point.inc
98
99 # There should be a message in the error log of the slave stating
100 # that it was waiting for space to write on the relay log.
101 --let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.2.err
102 # Grep only after the message that the I/O thread has started
103 --let $assert_only_after= Replica I/O .* connected to source .*replication started in log .* at position
104 --let $assert_count= 1
105 --let $assert_select=Disk is full writing .*$relay_log_file.* No space left on device
106 --let $assert_text= Found the disk full error message on the slave
107 --source include/assert_grep.inc
108
109 # There should be a message in the error log of the slave stating
110 # that it truncate the relay log file.
111 --let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.2.err
112 # Grep only after the message that the I/O thread has started
113 --let $assert_only_after= Replica receiver thread.* connected to source .* with server_uuid
114 --let $assert_count= 1
115 --let $assert_select= Relaylog file .* size was .* but was truncated at
116 --let $assert_text= Found the relay log truncate message on the slave
117 --source include/assert_grep.inc
118
119 # Start the I/O thread to let the slave to sync
120 --source include/start_slave_io.inc
121 --source include/rpl_connection_master.inc
122 --source include/sync_slave_sql_with_master.inc
123
124 --echo #
125 --echo # Step 2 - Restart the slave server while I/O thread is waiting for disk space
126 --echo #
127
128 # Set the debug option that will simulate disk full
129 --let $debug_point=simulate_io_thd_wait_for_disk_space
130 --source include/add_debug_point.inc
131
132 # Generate events to be replicated to the slave
133 --source include/rpl_connection_master.inc
134 INSERT INTO t1 VALUES(3);
135 INSERT INTO t1 VALUES(4);
136 INSERT INTO t1 VALUES(5);
137 INSERT INTO t1 VALUES(6);
138 INSERT INTO t1 VALUES(7);
139 INSERT INTO t1 VALUES(8);
140 INSERT INTO t1 VALUES(9);
141
142 --source include/rpl_connection_slave.inc
143 # Wait until IO thread is waiting for disk space
144 # Notice that this is performed by querying SHOW SLAVE STATUS
145 --let $slave_param= Slave_IO_State
146 --let $slave_param_value= Waiting for disk space
147 --source include/wait_for_slave_param.inc
148
149 # Restart the slave (relay log recovery is turned on and log error verbosity is 3)
150 --source include/stop_slave_sql.inc
151 --let $rpl_server_number= 2
152 --let $rpl_server_parameters=
153 --source include/rpl_restart_server.inc
154 --source include/start_slave.inc
155
156 # There should not be a message in the error log of the slave stating
157 # that it was waiting for space to stop the I/O thread.
158 --let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.2.err
159 # Grep only after the message that the I/O thread has started
160 --let $assert_only_after= Replica receiver thread.* connected to source .* with server_uuid
161 --let $assert_count= 0
162 --let $assert_select=Waiting until I/O thread for channel
163 --let $assert_text= Found no warning messages about I/O thread waiting before stopping
164 --source include/assert_grep.inc
165
166 # Cleanup
167 --source include/rpl_connection_master.inc
168 DROP TABLE t1;
169 --source include/sync_slave_sql_with_master.inc
170 --source include/rpl_end.inc