| 1 |
############################################################################### |
| 2 |
# WL#6630 Semisync separate acks collector |
| 3 |
# |
| 4 |
# In the worklog, a separate ack collector thread is added in semisync master |
| 5 |
# plugin. This test verifys the ack collector thread can works as expected. |
| 6 |
# |
| 7 |
# The thread is created when semisync master is enabled. and it is destroyed |
| 8 |
# when semisync master is disabled. |
| 9 |
################################################################################ |
| 10 |
--source include/not_valgrind.inc |
| 11 |
--source include/not_group_replication_plugin.inc |
| 12 |
--source include/have_debug.inc |
| 13 |
--source include/have_debug_sync.inc |
| 14 |
|
| 15 |
# server_1 is master, others are slaves. |
| 16 |
--let $rpl_topology= 1->2, 1->3, 1->4 |
| 17 |
--source include/rpl_init.inc |
| 18 |
--let $rpl_connection_name= server_1 |
| 19 |
--source include/rpl_connection.inc |
| 20 |
# Suppress warning: |
| 21 |
# "Semi-sync master failed on net_flush() before waiting for replica reply" |
| 22 |
CALL mtr.add_suppression("Semi-sync source failed on net_flush().*"); |
| 23 |
|
| 24 |
--echo #################################################################### |
| 25 |
--echo # Test Case: semisync master can be enabled and disabled sucessfully |
| 26 |
--echo # without any live slave connection and also test ON, OFF can be set |
| 27 |
--echo # more than once without problems. |
| 28 |
--echo #################################################################### |
| 29 |
--let $semisync_source_enabled= OFF |
| 30 |
--source include/install_semisync_source.inc |
| 31 |
SET GLOBAL rpl_semi_sync_source_enabled= ON; |
| 32 |
SET GLOBAL rpl_semi_sync_source_enabled= ON; |
| 33 |
SET GLOBAL rpl_semi_sync_source_enabled= OFF; |
| 34 |
SET GLOBAL rpl_semi_sync_source_enabled= OFF; |
| 35 |
|
| 36 |
--echo #################################################################### |
| 37 |
--echo # Test Case: Semisync should work even semisync slaves are connected |
| 38 |
--echo # before semisync master enabled. |
| 39 |
--echo #################################################################### |
| 40 |
CREATE TABLE t1(c1 INT) ENGINE=InnoDB; |
| 41 |
--source include/rpl_sync.inc |
| 42 |
|
| 43 |
--let $rpl_connection_name= server_2 |
| 44 |
--source include/rpl_connection.inc |
| 45 |
--source include/install_semisync_replica.inc |
| 46 |
|
| 47 |
--let $rpl_connection_name= server_1 |
| 48 |
--source include/rpl_connection.inc |
| 49 |
SET GLOBAL rpl_semi_sync_source_enabled= ON; |
| 50 |
--source extra/rpl_tests/rpl_semi_sync_ack_thread.inc |
| 51 |
|
| 52 |
--echo #################################################################### |
| 53 |
--echo # Test Case: Semisync should work when more than one semisync slaves |
| 54 |
--echo # connectted. |
| 55 |
--echo #################################################################### |
| 56 |
--let $rpl_connection_name= server_3 |
| 57 |
--source include/rpl_connection.inc |
| 58 |
--source include/install_semisync_replica.inc |
| 59 |
--source extra/rpl_tests/rpl_semi_sync_ack_thread.inc |
| 60 |
|
| 61 |
--let $rpl_connection_name= server_4 |
| 62 |
--source include/rpl_connection.inc |
| 63 |
--source include/install_semisync_replica.inc |
| 64 |
|
| 65 |
--source extra/rpl_tests/rpl_semi_sync_ack_thread.inc |
| 66 |
|
| 67 |
--echo ################################################################### |
| 68 |
--echo # Test Case: Semisync should work after semisync master is disabled |
| 69 |
--echo # and enabled again. |
| 70 |
--echo ################################################################### |
| 71 |
--let $rpl_connection_name= server_1 |
| 72 |
--source include/rpl_connection.inc |
| 73 |
|
| 74 |
SET GLOBAL rpl_semi_sync_source_enabled= OFF; |
| 75 |
INSERT INTO t1 VALUES(0); |
| 76 |
SET GLOBAL rpl_semi_sync_source_enabled= ON; |
| 77 |
--source extra/rpl_tests/rpl_semi_sync_ack_thread.inc |
| 78 |
|
| 79 |
--echo ################################################################### |
| 80 |
--echo # Test Case: Semisync should still work after some semisync slaves |
| 81 |
--echo # reconnected |
| 82 |
--echo ################################################################### |
| 83 |
--let $rpl_connection_name= server_2 |
| 84 |
--source include/rpl_connection.inc |
| 85 |
--source include/stop_slave_io.inc |
| 86 |
--source include/start_slave_io.inc |
| 87 |
|
| 88 |
--source extra/rpl_tests/rpl_semi_sync_ack_thread.inc |
| 89 |
|
| 90 |
--let $rpl_connection_name= server_3 |
| 91 |
--source include/rpl_connection.inc |
| 92 |
--source include/stop_slave_io.inc |
| 93 |
--source include/start_slave_io.inc |
| 94 |
|
| 95 |
--source extra/rpl_tests/rpl_semi_sync_ack_thread.inc |
| 96 |
|
| 97 |
--echo ################################################################### |
| 98 |
--echo # Test Case: Semisync should still work after some semisync slaves |
| 99 |
--echo # disconnected |
| 100 |
--echo ################################################################### |
| 101 |
--let $rpl_connection_name= server_2 |
| 102 |
--source include/rpl_connection.inc |
| 103 |
--source include/uninstall_semisync_replica.inc |
| 104 |
|
| 105 |
--source extra/rpl_tests/rpl_semi_sync_ack_thread.inc |
| 106 |
|
| 107 |
--let $rpl_connection_name= server_3 |
| 108 |
--source include/rpl_connection.inc |
| 109 |
--source include/uninstall_semisync_replica.inc |
| 110 |
|
| 111 |
--source extra/rpl_tests/rpl_semi_sync_ack_thread.inc |
| 112 |
|
| 113 |
--echo ##################################################################### |
| 114 |
--echo # Test Case: PS threads table includes ACK thread's status correctly. |
| 115 |
--echo ##################################################################### |
| 116 |
|
| 117 |
--echo # |
| 118 |
--echo # Status: Waiting for semi-sync ACK from replica |
| 119 |
--echo # |
| 120 |
|
| 121 |
# It may still in ack reading state, but it should change to ack waiting state. |
| 122 |
--let $wait_condition= SELECT count(*) = 1 FROM performance_schema.threads WHERE PROCESSLIST_STATE = 'Waiting for semi-sync ACK from replica' |
| 123 |
--source include/wait_condition.inc |
| 124 |
|
| 125 |
--let $rpl_connection_name= server_1 |
| 126 |
--source include/rpl_connection.inc |
| 127 |
SELECT name, type, processlist_state FROM performance_schema.threads |
| 128 |
WHERE name LIKE "%Ack_receiver"; |
| 129 |
|
| 130 |
--echo # |
| 131 |
--echo # Coverage Test: |
| 132 |
--echo # It should print an error to log if select() function returns -1 |
| 133 |
--echo # |
| 134 |
|
| 135 |
SET @save_debug = @@GLOBAL.debug; |
| 136 |
SET GLOBAL debug = '+d,rpl_semisync_simulate_select_error'; |
| 137 |
|
| 138 |
# wait enough time to guarantee that select() timeout happens |
| 139 |
--sleep 2 |
| 140 |
|
| 141 |
# It can still receive ACK from semi-sync slave |
| 142 |
INSERT INTO t1 VALUES(1); |
| 143 |
|
| 144 |
SET GLOBAL debug = @save_debug; |
| 145 |
|
| 146 |
--echo # |
| 147 |
--echo # Status: Waiting for semisync slave to connect |
| 148 |
--echo # |
| 149 |
--let $rpl_connection_name= server_4 |
| 150 |
--source include/rpl_connection.inc |
| 151 |
--source include/uninstall_semisync_replica.inc |
| 152 |
|
| 153 |
--let $rpl_connection_name= server_1 |
| 154 |
--source include/rpl_connection.inc |
| 155 |
# It guarantees semisync slave 5 is alrealdy unregistered from semisync master |
| 156 |
CALL mtr.add_suppression("Timeout waiting for reply of binlog.*"); |
| 157 |
INSERT INTO t1 VALUES(1); |
| 158 |
--save_master_pos |
| 159 |
|
| 160 |
--let $rpl_connection_name= server_4 |
| 161 |
--source include/rpl_connection.inc |
| 162 |
--sync_with_master |
| 163 |
|
| 164 |
--let $rpl_connection_name= server_1 |
| 165 |
--source include/rpl_connection.inc |
| 166 |
SELECT name, type, processlist_state FROM performance_schema.threads |
| 167 |
WHERE name LIKE "%Ack_receiver"; |
| 168 |
|
| 169 |
--echo # |
| 170 |
--echo # Ack thread is stopped, it should be not in PS.threads table. |
| 171 |
--echo # |
| 172 |
SET GLOBAL rpl_semi_sync_source_enabled= OFF; |
| 173 |
|
| 174 |
--let $assert_text= ack receiver thread is destroied |
| 175 |
--let $assert_cond= count(*) = 0 FROM performance_schema.threads WHERE name LIKE "%Ack_receiver" |
| 176 |
--source include/assert.inc |
| 177 |
|
| 178 |
--echo ############################################ |
| 179 |
--echo # Test Case: Coverage test on error branches |
| 180 |
--echo ############################################ |
| 181 |
SET @save_debug = @@GLOBAL.debug; |
| 182 |
CALL mtr.add_suppression("Failed to start semi-sync ACK receiver thread.*"); |
| 183 |
CALL mtr.add_suppression("Failed to register replica to semi-sync ACK receiver thread.*"); |
| 184 |
CALL mtr.add_suppression("Failed to stop ack receiver thread on my_thread_join.*"); |
| 185 |
CALL mtr.add_suppression("Run function 'transmit_start' .* failed"); |
| 186 |
|
| 187 |
SET GLOBAL rpl_semi_sync_source_trace_level = 255; |
| 188 |
--echo # |
| 189 |
--echo # Failure on creating ack receiver thread |
| 190 |
--echo # |
| 191 |
SET GLOBAL debug = '+d,rpl_semisync_simulate_create_thread_failure'; |
| 192 |
SET GLOBAL rpl_semi_sync_source_enabled= ON; |
| 193 |
|
| 194 |
--let $assert_variable_name= rpl_semi_sync_source_enabled |
| 195 |
--let $assert_variable_value= 0 |
| 196 |
--source include/assert_variable.inc |
| 197 |
|
| 198 |
--let $assert_text= ack receiver thread is destroied; |
| 199 |
--let $assert_cond= count(*) = 0 FROM performance_schema.threads WHERE name LIKE "%Ack_receiver" |
| 200 |
--source include/assert.inc |
| 201 |
|
| 202 |
--echo # |
| 203 |
--echo # Failure on stopping ack receive thread |
| 204 |
--echo # |
| 205 |
|
| 206 |
SET GLOBAL debug= @save_debug; |
| 207 |
SET GLOBAL rpl_semi_sync_source_enabled= ON; |
| 208 |
|
| 209 |
SET GLOBAL debug= '+d,rpl_semisync_simulate_thread_join_failure'; |
| 210 |
SET GLOBAL rpl_semi_sync_source_enabled= OFF; |
| 211 |
|
| 212 |
--let $assert_variable_name= rpl_semi_sync_source_enabled |
| 213 |
--let $assert_variable_value= 0 |
| 214 |
--source include/assert_variable.inc |
| 215 |
|
| 216 |
--let $assert_text= ack receiver thread is destroied |
| 217 |
--let $assert_cond= count(*) = 0 FROM performance_schema.threads WHERE name LIKE "%Ack_receiver" |
| 218 |
--source include/assert.inc |
| 219 |
|
| 220 |
--echo # |
| 221 |
--echo # Failure on registering semisync slave |
| 222 |
--echo # |
| 223 |
SET GLOBAL debug= '-d,rpl_semisync_simulate_thread_join_failure'; |
| 224 |
SET GLOBAL debug= '+d,rpl_semisync_simulate_add_replica_failure'; |
| 225 |
SET GLOBAL rpl_semi_sync_source_enabled= ON; |
| 226 |
|
| 227 |
--let $rpl_connection_name= server_2 |
| 228 |
--source include/rpl_connection.inc |
| 229 |
--source include/stop_slave.inc |
| 230 |
--let $save_retry_count= query_get_value(SHOW SLAVE STATUS, Master_Retry_Count, 1) |
| 231 |
--let $save_retry_time= query_get_value(SHOW SLAVE STATUS, Connect_Retry, 1) |
| 232 |
CHANGE REPLICATION SOURCE TO SOURCE_RETRY_COUNT = 1, SOURCE_CONNECT_RETRY = 5; |
| 233 |
|
| 234 |
# Make IO thread hungs after connecting to master. So we can make sure it is |
| 235 |
# stopped by add_slave_failure |
| 236 |
SET @save_debug= @@GLOBAL.debug; |
| 237 |
SET GLOBAL debug= '+d,dbug.before_get_SOURCE_UUID'; |
| 238 |
--source include/install_semisync_replica.inc |
| 239 |
|
| 240 |
# Clear the debug point and signal IO thread to resume |
| 241 |
SET GLOBAL debug= @save_debug; |
| 242 |
SET debug_sync= 'now SIGNAL signal.get_source_uuid'; |
| 243 |
|
| 244 |
# It should be stopped by add_slave failure |
| 245 |
--source include/wait_for_slave_io_to_stop.inc |
| 246 |
|
| 247 |
eval CHANGE REPLICATION SOURCE TO SOURCE_RETRY_COUNT = $save_retry_count, |
| 248 |
SOURCE_CONNECT_RETRY = $save_retry_time; |
| 249 |
|
| 250 |
--source include/uninstall_semisync_replica.inc |
| 251 |
--source include/start_slave_sql.inc |
| 252 |
|
| 253 |
--let $rpl_connection_name= server_1 |
| 254 |
--source include/rpl_connection.inc |
| 255 |
DROP TABLE t1; |
| 256 |
--source include/rpl_sync.inc |
| 257 |
|
| 258 |
SET GLOBAL debug= @save_debug; |
| 259 |
--source include/uninstall_semisync_source.inc |
| 260 |
--source include/rpl_end.inc |