|
| 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 master pos"); |
| 41 | +CALL mtr.add_suppression("Waiting until I/O thread .* finish writing to disk before stopping"); |
| 42 | + |
| 43 | +--echo # |
| 44 | +--echo # Step 1 - Monitor and kill I/O thread while waiting for disk space |
| 45 | +--echo # |
| 46 | + |
| 47 | +--let $io_id=`SELECT PROCESSLIST_ID FROM performance_schema.threads WHERE NAME = 'thread/sql/slave_io'` |
| 48 | + |
| 49 | +# Set the debug option that will simulate disk full |
| 50 | +--let $debug_point=simulate_io_thd_wait_for_disk_space |
| 51 | +--source include/add_debug_point.inc |
| 52 | + |
| 53 | +# Generate events to be replicated to the slave |
| 54 | +--source include/rpl_connection_master.inc |
| 55 | +INSERT INTO t1 VALUES(2); |
| 56 | + |
| 57 | +--source include/rpl_connection_slave.inc |
| 58 | +# Wait until IO thread is waiting for disk space |
| 59 | +# Notice that this is performed by querying SHOW SLAVE STATUS |
| 60 | +--let $slave_param= Slave_IO_State |
| 61 | +--let $slave_param_value= Waiting for disk space |
| 62 | +--source include/wait_for_slave_param.inc |
| 63 | + |
| 64 | +# performance_schema.threads and information_schema.processlist checks |
| 65 | +--let $io_state=`SELECT PROCESSLIST_STATE FROM performance_schema.threads WHERE NAME = 'thread/sql/slave_io'` |
| 66 | +--let $assert_text= I/O thread PROCESSLIST_STATE should be Waiting for disk space at performance_schema.threads |
| 67 | +--let $assert_cond= "$io_state" = "Waiting for disk space" |
| 68 | +--source include/assert.inc |
| 69 | + |
| 70 | +--let $io_state=`SELECT STATE FROM information_schema.processlist WHERE ID = $io_id` |
| 71 | +--let $assert_text= I/O thread STATE should be Waiting for disk space at information_schema.processlist |
| 72 | +--let $assert_cond= "$io_state" = "Waiting for disk space" |
| 73 | +--source include/assert.inc |
| 74 | + |
| 75 | +# Get the relay log file name, also using SHOW SLAVE STATUS |
| 76 | +--let $relay_log_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1) |
| 77 | + |
| 78 | +# STOP SLAVE IO_THREAD should be blocked |
| 79 | +--source include/rpl_connection_slave1.inc |
| 80 | +--send STOP SLAVE IO_THREAD |
| 81 | + |
| 82 | +# But the KILL on it should unblock it |
| 83 | +--source include/rpl_connection_slave.inc |
| 84 | +SET DEBUG_SYNC="now WAIT_FOR reached_stopping_io_thread"; |
| 85 | +--replace_result $io_id IO_THREAD |
| 86 | +--eval KILL $io_id |
| 87 | + |
| 88 | +--source include/rpl_connection_slave1.inc |
| 89 | +--reap |
| 90 | + |
| 91 | +--source include/rpl_connection_slave.inc |
| 92 | +--let $slave_io_errno= convert_error(ER_SLAVE_RELAY_LOG_WRITE_FAILURE) |
| 93 | +--source include/wait_for_slave_io_error.inc |
| 94 | + |
| 95 | +# Restore the debug options to "simulate" freed space on disk |
| 96 | +--source include/remove_debug_point.inc |
| 97 | + |
| 98 | +# There should be a message in the error log of the slave stating |
| 99 | +# that it was waiting for space to write on the relay log. |
| 100 | +--let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.2.err |
| 101 | +# Grep only after the message that the I/O thread has started |
| 102 | +--let $assert_only_after= Slave I/O .* connected to master .*replication started in log .* at position |
| 103 | +--let $assert_count= 1 |
| 104 | +--let $assert_select=Disk is full writing .*$relay_log_file.* No space left on device |
| 105 | +--let $assert_text= Found the disk full error message on the slave |
| 106 | +--source include/assert_grep.inc |
| 107 | + |
| 108 | +# There should be a message in the error log of the slave stating |
| 109 | +# that it truncate the relay log file. |
| 110 | +--let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.2.err |
| 111 | +# Grep only after the message that the I/O thread has started |
| 112 | +--let $assert_only_after= Slave I/O .* connected to master .*replication started in log .* at position |
| 113 | +--let $assert_count= 1 |
| 114 | +--let $assert_select= Relaylog file .* size was .* but was truncated at |
| 115 | +--let $assert_text= Found the relay log truncate message on the slave |
| 116 | +--source include/assert_grep.inc |
| 117 | + |
| 118 | +# Start the I/O thread to let the slave to sync |
| 119 | +--source include/start_slave_io.inc |
| 120 | +--source include/rpl_connection_master.inc |
| 121 | +--source include/sync_slave_sql_with_master.inc |
| 122 | + |
| 123 | +--echo # |
| 124 | +--echo # Step 2 - Restart the slave server while I/O thread is waiting for disk space |
| 125 | +--echo # |
| 126 | + |
| 127 | +# Set the debug option that will simulate disk full |
| 128 | +--let $debug_point=simulate_io_thd_wait_for_disk_space |
| 129 | +--source include/add_debug_point.inc |
| 130 | + |
| 131 | +# Generate events to be replicated to the slave |
| 132 | +--source include/rpl_connection_master.inc |
| 133 | +INSERT INTO t1 VALUES(3); |
| 134 | +INSERT INTO t1 VALUES(4); |
| 135 | +INSERT INTO t1 VALUES(5); |
| 136 | +INSERT INTO t1 VALUES(6); |
| 137 | +INSERT INTO t1 VALUES(7); |
| 138 | +INSERT INTO t1 VALUES(8); |
| 139 | +INSERT INTO t1 VALUES(9); |
| 140 | + |
| 141 | +--source include/rpl_connection_slave.inc |
| 142 | +# Wait until IO thread is waiting for disk space |
| 143 | +# Notice that this is performed by querying SHOW SLAVE STATUS |
| 144 | +--let $slave_param= Slave_IO_State |
| 145 | +--let $slave_param_value= Waiting for disk space |
| 146 | +--source include/wait_for_slave_param.inc |
| 147 | + |
| 148 | +# Restart the slave with relay log recovery |
| 149 | +--source include/stop_slave_sql.inc |
| 150 | +--let $rpl_server_number= 2 |
| 151 | +--let $rpl_server_parameters= --relay_log_recovery |
| 152 | +--source include/rpl_restart_server.inc |
| 153 | +--source include/start_slave.inc |
| 154 | + |
| 155 | +# There should not be a message in the error log of the slave stating |
| 156 | +# that it was waiting for space to stop the I/O thread. |
| 157 | +--let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.2.err |
| 158 | +# Grep only after the message that the I/O thread has started |
| 159 | +--let $assert_only_after= Slave I/O .* connected to master .*replication started in log .* at position |
| 160 | +--let $assert_count= 0 |
| 161 | +--let $assert_select=Waiting until I/O thread for channel |
| 162 | +--let $assert_text= Found no warning messages about I/O thread waiting before stopping |
| 163 | +--source include/assert_grep.inc |
| 164 | + |
| 165 | +# Cleanup |
| 166 | +--source include/rpl_connection_master.inc |
| 167 | +DROP TABLE t1; |
| 168 | +--source include/rpl_end.inc |
0 commit comments