| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# This test case will test if a server will not fail to know that the |
| 4 |
# replication threads are stopping. |
| 5 |
# |
| 6 |
# The applier thread test: |
| 7 |
# |
| 8 |
# The test case generate a situation that will result into a SQL thread |
| 9 |
# error. The error will not happen during the thread startup, so the |
| 10 |
# "START SLAVE" command will succeed. |
| 11 |
# |
| 12 |
# The plug-in, once activated a certain debug point, will: |
| 13 |
# a) unregister the thread stop hook; |
| 14 |
# b) start the slave I/O thread |
| 15 |
# c) start the slave SQL thread |
| 16 |
# d) wait until SQL thread reach the error point |
| 17 |
# e) register the thread stop hook; |
| 18 |
# f) assert that the SQL thread is still considered as active |
| 19 |
# g) assert that the SQL thread is considered as stopping |
| 20 |
# h) assert that the plug-in has missed the thread stop hook |
| 21 |
# |
| 22 |
# The receiver thread test: |
| 23 |
# |
| 24 |
# The test case generate a situation that will result into a I/O thread |
| 25 |
# error. The error will not happen during the thread startup, so the |
| 26 |
# "START SLAVE IO_THREAD" command will succeed. |
| 27 |
# |
| 28 |
# The plug-in, once activated a certain debug point, will: |
| 29 |
# a) unregister the thread stop hook; |
| 30 |
# b) start the slave I/O thread |
| 31 |
# c) wait until I/O thread reach the error point |
| 32 |
# d) register the thread stop hook; |
| 33 |
# e) assert that the I/O thread is still considered as active |
| 34 |
# f) assert that the I/O thread is considered as stopping |
| 35 |
# g) assert that the plug-in has missed the thread stop hook |
| 36 |
# |
| 37 |
# Before having the "stopping" flag, a replication thread could be |
| 38 |
# considered as active after registering to monitor its thread stop |
| 39 |
# hook, but never getting the thread stop signal because the thread |
| 40 |
# was in a state that would not generate the thread stop signal |
| 41 |
# anymore. |
| 42 |
# |
| 43 |
# ==== Related Bugs and Worklogs ==== |
| 44 |
# |
| 45 |
# BUG#23618316 MONITORING THREAD MIGHT MISS THREAD STOP SIGNAL FROM RPL |
| 46 |
# THREADS HOOKS |
| 47 |
# |
| 48 |
--source include/not_group_replication_plugin.inc |
| 49 |
--source include/have_debug.inc |
| 50 |
--source include/have_debug_sync.inc |
| 51 |
--source include/have_replication_observers_example_plugin.inc |
| 52 |
# This test case is binary log format agnostic |
| 53 |
--source include/have_binlog_format_mixed.inc |
| 54 |
# Test requires master-info-repository=TABLE, relay-log-info-repository=TABLE |
| 55 |
--source include/have_slave_repository_type_table.inc |
| 56 |
# This test cannot run with MTS |
| 57 |
--source include/not_mts_replica_parallel_workers.inc |
| 58 |
--let $rpl_skip_start_slave= 1 |
| 59 |
--source include/master-slave.inc |
| 60 |
|
| 61 |
--echo |
| 62 |
--echo ############################################################ |
| 63 |
--echo # 1. Install the plug-in and add error suppressions on slave |
| 64 |
|
| 65 |
--source include/rpl_connection_master.inc |
| 66 |
SET SESSION sql_log_bin= 0; |
| 67 |
CALL mtr.add_suppression(".*Cannot replicate.*purged required binary logs.*"); |
| 68 |
SET SESSION sql_log_bin= 1; |
| 69 |
|
| 70 |
--source include/rpl_connection_slave.inc |
| 71 |
SET SESSION sql_log_bin= 0; |
| 72 |
CALL mtr.add_suppression("Table 't1' already exists"); |
| 73 |
CALL mtr.add_suppression("Got fatal error 1236 from source when reading data from binary log"); |
| 74 |
SET SESSION sql_log_bin= 1; |
| 75 |
--source include/install_replication_observers_example.inc |
| 76 |
|
| 77 |
--echo |
| 78 |
--echo #################################################################### |
| 79 |
--echo # 2. Create a table on master and generate workload to be replicated |
| 80 |
|
| 81 |
--source include/rpl_connection_master.inc |
| 82 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 83 |
INSERT INTO t1 VALUES (1); |
| 84 |
|
| 85 |
--echo |
| 86 |
--echo ######################################## |
| 87 |
--echo # 3. Create the example_channel on slave |
| 88 |
|
| 89 |
--source include/rpl_connection_slave.inc |
| 90 |
--replace_result $MASTER_MYPORT MASTER_MYPORT |
| 91 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_HOST='127.0.0.1', SOURCE_PORT=$MASTER_MYPORT, SOURCE_USER='root', SOURCE_AUTO_POSITION=1 FOR CHANNEL 'example_channel' |
| 92 |
|
| 93 |
--echo |
| 94 |
--echo ####################### |
| 95 |
--echo # 4. SQL thread testing |
| 96 |
|
| 97 |
--echo |
| 98 |
--echo ################################################# |
| 99 |
--echo # 4.1 Prepare SQL thread to fail after started up |
| 100 |
|
| 101 |
# This is to make the SQL thread to fail |
| 102 |
SET SESSION sql_log_bin= 0; |
| 103 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 104 |
SET SESSION sql_log_bin= 1; |
| 105 |
|
| 106 |
# Set the debug point to test using the plug-in |
| 107 |
--let $debug_point=validate_replication_observers_plugin_server_is_sql_stopping |
| 108 |
--source include/add_debug_point.inc |
| 109 |
# Set the debug point to test the SQL thread |
| 110 |
--let $debug_point=pause_after_sql_thread_stop_hook |
| 111 |
--source include/add_debug_point.inc |
| 112 |
|
| 113 |
# Activate the test function in the plug-in |
| 114 |
# It will take care of starting the SQL thread |
| 115 |
--source include/rpl_connection_slave1.inc |
| 116 |
SET SESSION sql_log_bin= 0; |
| 117 |
--send INSERT INTO t1 VALUES (0) |
| 118 |
|
| 119 |
--echo |
| 120 |
--echo ######################################################### |
| 121 |
--echo # 4.2 Wait until SQL thread failed trying to apply events |
| 122 |
|
| 123 |
--source include/rpl_connection_slave.inc |
| 124 |
# Wait until the plug-in has stated the SQL thread |
| 125 |
SET DEBUG_SYNC='now WAIT_FOR reached_sql_thread_started'; |
| 126 |
|
| 127 |
# Wait until the SQL thread has failed |
| 128 |
--let $slave_sql_errno= convert_error(ER_TABLE_EXISTS_ERROR) |
| 129 |
--let $rpl_channel_name= 'example_channel' |
| 130 |
--source include/wait_for_slave_sql_error.inc |
| 131 |
|
| 132 |
# Remove debug instrumentation |
| 133 |
--let $debug_point=pause_after_sql_thread_stop_hook |
| 134 |
--source include/remove_debug_point.inc |
| 135 |
--let $debug_point=validate_replication_observers_plugin_server_is_sql_stopping |
| 136 |
--source include/remove_debug_point.inc |
| 137 |
|
| 138 |
# Cleanup of step 4 |
| 139 |
--source include/rpl_connection_slave1.inc |
| 140 |
--reap |
| 141 |
SET SESSION sql_log_bin= 1; |
| 142 |
--source include/stop_slave.inc |
| 143 |
RESET SLAVE FOR CHANNEL 'example_channel'; |
| 144 |
|
| 145 |
--echo |
| 146 |
--echo ####################### |
| 147 |
--echo # 5. I/O thread testing |
| 148 |
|
| 149 |
--echo |
| 150 |
--echo ########################################################################## |
| 151 |
--echo # 5.1 Rotate and purge the binary log on master to make I/O thread to fail |
| 152 |
|
| 153 |
--source include/rpl_connection_master.inc |
| 154 |
FLUSH BINARY LOGS; |
| 155 |
--let $server_binlog_file_cur= query_get_value(SHOW MASTER STATUS, File, 1) |
| 156 |
|
| 157 |
# Need to kill the dump thread explicitly: stop slave does not do |
| 158 |
# that, and if the dump thread is slow, it will still be reading from |
| 159 |
# the old binlog at the time we do PURGE BINARY LOGS below. That would |
| 160 |
# prevent PURGE BINARY LOGS from purging the log. |
| 161 |
--source include/stop_dump_threads.inc |
| 162 |
|
| 163 |
--disable_query_log |
| 164 |
--eval PURGE BINARY LOGS TO '$server_binlog_file_cur' |
| 165 |
--enable_query_log |
| 166 |
|
| 167 |
--echo |
| 168 |
--echo ################################################# |
| 169 |
--echo # 5.2 Prepare I/O thread to fail after started up |
| 170 |
|
| 171 |
--source include/rpl_connection_slave.inc |
| 172 |
# Set the debug point to test using the plug-in |
| 173 |
--let $debug_point=validate_replication_observers_plugin_server_is_io_stopping |
| 174 |
--source include/add_debug_point.inc |
| 175 |
# Set the debug point to test the I/O thread |
| 176 |
--let $debug_point=pause_after_io_thread_stop_hook |
| 177 |
--source include/add_debug_point.inc |
| 178 |
|
| 179 |
# Activate the test function in the plug-in |
| 180 |
# It will take care of starting the I/O thread |
| 181 |
--source include/rpl_connection_slave1.inc |
| 182 |
SET SESSION sql_log_bin= 0; |
| 183 |
--send INSERT INTO t1 VALUES (1) |
| 184 |
|
| 185 |
--echo |
| 186 |
--echo ########################################################### |
| 187 |
--echo # 5.3 Wait until I/O thread failed to replicate from master |
| 188 |
|
| 189 |
--source include/rpl_connection_slave.inc |
| 190 |
# Wait until the plug-in has stated the I/O thread |
| 191 |
SET DEBUG_SYNC='now WAIT_FOR reached_io_thread_started'; |
| 192 |
|
| 193 |
--let $slave_io_errno= convert_error(ER_SERVER_SOURCE_FATAL_ERROR_READING_BINLOG) |
| 194 |
--let $rpl_channel_name= 'example_channel' |
| 195 |
--source include/wait_for_slave_io_error.inc |
| 196 |
|
| 197 |
# Remove debug instrumentation |
| 198 |
--let $debug_point=pause_after_io_thread_stop_hook |
| 199 |
--source include/remove_debug_point.inc |
| 200 |
--let $debug_point=validate_replication_observers_plugin_server_is_io_stopping |
| 201 |
--source include/remove_debug_point.inc |
| 202 |
|
| 203 |
# Cleanup of step 5 |
| 204 |
--source include/rpl_connection_slave1.inc |
| 205 |
--reap |
| 206 |
DROP TABLE t1; |
| 207 |
SET SESSION sql_log_bin= 1; |
| 208 |
|
| 209 |
--echo |
| 210 |
--echo ############ |
| 211 |
--echo # 6. Cleanup |
| 212 |
|
| 213 |
--source include/rpl_connection_slave.inc |
| 214 |
# Remove the example_channel on the slave |
| 215 |
RESET SLAVE ALL FOR CHANNEL 'example_channel'; |
| 216 |
# Remove the plug-in on the slave |
| 217 |
--source include/uninstall_replication_observers_example.inc |
| 218 |
|
| 219 |
# Cleanup the master to be able to replicate from it again |
| 220 |
--source include/rpl_connection_master.inc |
| 221 |
DROP TABLE t1; |
| 222 |
RESET MASTER; |
| 223 |
|
| 224 |
--source include/rpl_connection_slave.inc |
| 225 |
# Start the default channel slave threads |
| 226 |
--let $rpl_channel_name= |
| 227 |
--source include/start_slave.inc |
| 228 |
|
| 229 |
--source include/rpl_end.inc |