| 1 |
################################################################################ |
| 2 |
# WL#7169 Semisync: make master wait for more than one slave to ack back |
| 3 |
# |
| 4 |
# The worklog added semisync master variable |
| 5 |
# rpl_semi_sync_source_wait_for_replica_count. The variable controls how many acks |
| 6 |
# from different slaves the transaction should wait for. |
| 7 |
# |
| 8 |
# The test verifies rpl_semi_sync_source_wait_for_replica_count works well. |
| 9 |
################################################################################ |
| 10 |
--source include/not_group_replication_plugin.inc |
| 11 |
--source include/have_debug.inc |
| 12 |
|
| 13 |
--let rpl_topology=1->2, 1->3, 1->4, 1->5 |
| 14 |
--source include/rpl_init.inc |
| 15 |
CREATE TABLE t1(c1 INT); |
| 16 |
--source include/rpl_sync.inc |
| 17 |
|
| 18 |
--let $rpl_connection_name= server_1 |
| 19 |
--source include/rpl_connection.inc |
| 20 |
--source include/install_semisync_source.inc |
| 21 |
|
| 22 |
# It is for coverage test to cover the debug code. |
| 23 |
SET GLOBAL rpl_semi_sync_source_trace_level= 255; |
| 24 |
|
| 25 |
--echo #################################################################### |
| 26 |
--echo # Test Case: Wait ack from 1 slave, but no semisync slave is enabled |
| 27 |
--echo #################################################################### |
| 28 |
--source include/save_semisync_yesno_tx.inc |
| 29 |
|
| 30 |
# The statement will timeout, just make a smaller wait time. |
| 31 |
SET GLOBAL rpl_semi_sync_source_timeout=3000; |
| 32 |
INSERT INTO t1 VALUES(1); |
| 33 |
|
| 34 |
--let $semi_sync_no_tx_increment= 1 |
| 35 |
--source include/assert_semisync_yesno_tx_increment.inc |
| 36 |
|
| 37 |
--echo ################################################################### |
| 38 |
--echo # Test Case: Wait ack from 1 slave, and 1 semisync slave is enabled |
| 39 |
--echo ################################################################### |
| 40 |
--let $rpl_connection_name= server_2 |
| 41 |
--source include/rpl_connection.inc |
| 42 |
--source include/install_semisync_replica.inc |
| 43 |
|
| 44 |
--let $rpl_connection_name= server_1 |
| 45 |
--source include/rpl_connection.inc |
| 46 |
--source include/wait_for_semisync_source_status_on.inc |
| 47 |
--source include/save_semisync_yesno_tx.inc |
| 48 |
|
| 49 |
SET GLOBAL rpl_semi_sync_source_timeout=100000; |
| 50 |
INSERT INTO t1 VALUES(3); |
| 51 |
INSERT INTO t1 VALUES(4); |
| 52 |
|
| 53 |
--let $semi_sync_yes_tx_increment= 2 |
| 54 |
--source include/assert_semisync_yesno_tx_increment.inc |
| 55 |
|
| 56 |
--echo ######################################################################### |
| 57 |
--echo # Test Case: Wait ack from 2 slaves, but only 1 semisync slave is enabled |
| 58 |
--echo ######################################################################### |
| 59 |
--source include/save_semisync_yesno_tx.inc |
| 60 |
|
| 61 |
SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = 2; |
| 62 |
SET GLOBAL rpl_semi_sync_source_timeout=3000; |
| 63 |
|
| 64 |
INSERT INTO t1 VALUES(10); |
| 65 |
|
| 66 |
--let $semi_sync_no_tx_increment= 1 |
| 67 |
--source include/assert_semisync_yesno_tx_increment.inc |
| 68 |
|
| 69 |
--echo ##################################################################### |
| 70 |
--echo # Test Case: Wait ack from 2 slaves, and 2 semisync slave are enabled |
| 71 |
--echo ##################################################################### |
| 72 |
--let $rpl_connection_name= server_3 |
| 73 |
--source include/rpl_connection.inc |
| 74 |
--source include/install_semisync_replica.inc |
| 75 |
|
| 76 |
--let $rpl_connection_name= server_1 |
| 77 |
--source include/rpl_connection.inc |
| 78 |
--source include/wait_for_semisync_source_status_on.inc |
| 79 |
--source include/save_semisync_yesno_tx.inc |
| 80 |
|
| 81 |
SET GLOBAL rpl_semi_sync_source_timeout = 100000; |
| 82 |
INSERT INTO t1 VALUES(102); |
| 83 |
INSERT INTO t1 VALUES(103); |
| 84 |
|
| 85 |
--let $semi_sync_yes_tx_increment= 2 |
| 86 |
--source include/assert_semisync_yesno_tx_increment.inc |
| 87 |
|
| 88 |
--echo ########################################################################## |
| 89 |
--echo # Test Case: Wait ack from 3 slaves, but only 2 semisync slave are enabled |
| 90 |
--echo ########################################################################## |
| 91 |
--source include/save_semisync_yesno_tx.inc |
| 92 |
|
| 93 |
SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = 3; |
| 94 |
SET GLOBAL rpl_semi_sync_source_timeout = 3000; |
| 95 |
INSERT INTO t1 VALUES(100); |
| 96 |
INSERT INTO t1 VALUES(101); |
| 97 |
|
| 98 |
--let $semi_sync_no_tx_increment= 2 |
| 99 |
--source include/assert_semisync_yesno_tx_increment.inc |
| 100 |
|
| 101 |
--echo ###################################################################### |
| 102 |
--echo # Test Case: Wait ack from 3 slaves, and 3 semisync slaves are enabled |
| 103 |
--echo ###################################################################### |
| 104 |
--let $rpl_connection_name= server_4 |
| 105 |
--source include/rpl_connection.inc |
| 106 |
--source include/install_semisync_replica.inc |
| 107 |
|
| 108 |
--let $rpl_connection_name= server_1 |
| 109 |
--source include/rpl_connection.inc |
| 110 |
--source include/wait_for_semisync_source_status_on.inc |
| 111 |
--source include/save_semisync_yesno_tx.inc |
| 112 |
|
| 113 |
SET GLOBAL rpl_semi_sync_source_timeout = 100000; |
| 114 |
INSERT INTO t1 VALUES(102); |
| 115 |
INSERT INTO t1 VALUES(103); |
| 116 |
|
| 117 |
--let $semi_sync_yes_tx_increment= 2 |
| 118 |
--source include/assert_semisync_yesno_tx_increment.inc |
| 119 |
|
| 120 |
--echo ###################################################################### |
| 121 |
--echo # Test Case: Verify only the transaction before replied ack position |
| 122 |
--echo # can stop waiting and go ahead. |
| 123 |
--echo ###################################################################### |
| 124 |
--let $rpl_connection_name= server_4 |
| 125 |
--source include/rpl_connection.inc |
| 126 |
SET @original_debug = @@GLOBAL.debug; |
| 127 |
SET GLOBAL debug = '+d,rpl_semisync_before_send_ack'; |
| 128 |
|
| 129 |
--let $rpl_connection_name= default |
| 130 |
--source include/rpl_connection.inc |
| 131 |
--source include/save_semisync_yesno_tx.inc |
| 132 |
|
| 133 |
--send INSERT INTO t1 VALUES(104) |
| 134 |
|
| 135 |
# Wait until above INSERT is replicated. It guarantees INSERT (104) is executed |
| 136 |
# before INSERT(105) |
| 137 |
--let $rpl_connection_name= server_2 |
| 138 |
--source include/rpl_connection.inc |
| 139 |
--let $wait_condition= SELECT COUNT(*) FROM t1 WHERE c1 = 104 |
| 140 |
--source include/wait_condition.inc |
| 141 |
|
| 142 |
--let $rpl_connection_name= server_1 |
| 143 |
--source include/rpl_connection.inc |
| 144 |
--send INSERT INTO t1 VALUES(105) |
| 145 |
|
| 146 |
# Wait until 105 is applied on both server_2 and server_3. It guarantees that |
| 147 |
# master has received acks from both server_2 and server_3. |
| 148 |
--let $rpl_connection_name= server_2 |
| 149 |
--source include/rpl_connection.inc |
| 150 |
--let $wait_condition= SELECT COUNT(*) FROM t1 WHERE c1 = 105 |
| 151 |
--source include/wait_condition.inc |
| 152 |
|
| 153 |
--let $rpl_connection_name= server_3 |
| 154 |
--source include/rpl_connection.inc |
| 155 |
--let $wait_condition= SELECT COUNT(*) FROM t1 WHERE c1 = 105 |
| 156 |
--source include/wait_condition.inc |
| 157 |
|
| 158 |
# Let server_4 send the first ack for INSERT (104) |
| 159 |
--let $rpl_connection_name= server_4 |
| 160 |
--source include/rpl_connection.inc |
| 161 |
SET DEBUG_SYNC = 'now SIGNAL continue'; |
| 162 |
|
| 163 |
--let $rpl_connection_name= default |
| 164 |
--source include/rpl_connection.inc |
| 165 |
--reap |
| 166 |
--let $semi_sync_yes_tx_increment= 1 |
| 167 |
--source include/assert_semisync_yesno_tx_increment.inc |
| 168 |
--source include/save_semisync_yesno_tx.inc |
| 169 |
|
| 170 |
# Let server_4 send the first ack for INSERT (105) |
| 171 |
--let $rpl_connection_name= server_4 |
| 172 |
--source include/rpl_connection.inc |
| 173 |
SET DEBUG_SYNC = 'now SIGNAL continue'; |
| 174 |
|
| 175 |
--let $rpl_connection_name= server_1 |
| 176 |
--source include/rpl_connection.inc |
| 177 |
--reap |
| 178 |
--let $semi_sync_yes_tx_increment= 1 |
| 179 |
--source include/assert_semisync_yesno_tx_increment.inc |
| 180 |
|
| 181 |
--echo ###################################################################### |
| 182 |
--echo # Test Case: Coverage test, it covers the branch that coming ack is |
| 183 |
--echo # greater than the acked already received. |
| 184 |
--echo ###################################################################### |
| 185 |
--let $rpl_connection_name= server_1 |
| 186 |
--source include/rpl_connection.inc |
| 187 |
--source include/save_semisync_yesno_tx.inc |
| 188 |
--send INSERT INTO t1 VALUES(130); |
| 189 |
|
| 190 |
--let $rpl_connection_name= server_2 |
| 191 |
--source include/rpl_connection.inc |
| 192 |
|
| 193 |
# The wait guarantees that it already sends the ack to master |
| 194 |
--let $wait_condition= SELECT count(*) FROM t1 WHERE c1 = 130; |
| 195 |
--source include/wait_condition.inc |
| 196 |
SET @original_debug = @@GLOBAL.debug; |
| 197 |
SET GLOBAL debug = '+d,rpl_semisync_before_send_ack'; |
| 198 |
|
| 199 |
--let $rpl_connection_name= server_3 |
| 200 |
--source include/rpl_connection.inc |
| 201 |
|
| 202 |
# The wait guarantees that it already sends the ack to master |
| 203 |
--let $wait_condition= SELECT count(*) FROM t1 WHERE c1 = 130; |
| 204 |
--source include/wait_condition.inc |
| 205 |
SET @original_debug = @@GLOBAL.debug; |
| 206 |
SET GLOBAL debug = '+d,rpl_semisync_before_send_ack'; |
| 207 |
|
| 208 |
--let $rpl_connection_name= default |
| 209 |
--source include/rpl_connection.inc |
| 210 |
--send INSERT INTO t1 VALUES(131); |
| 211 |
|
| 212 |
--let $rpl_connection_name= server_5 |
| 213 |
--source include/rpl_connection.inc |
| 214 |
|
| 215 |
# The wait guarantees that it already sends the ack to master |
| 216 |
--let $wait_condition= SELECT count(*) FROM t1 WHERE c1 = 131; |
| 217 |
--source include/wait_condition.inc |
| 218 |
--source include/install_semisync_replica.inc |
| 219 |
|
| 220 |
--let $rpl_connection_name= server_1 |
| 221 |
--source include/rpl_connection.inc |
| 222 |
--reap |
| 223 |
--let $semi_sync_yes_tx_increment= 1 |
| 224 |
--source include/assert_semisync_yesno_tx_increment.inc |
| 225 |
--source include/save_semisync_yesno_tx.inc |
| 226 |
|
| 227 |
--let $rpl_connection_name= server_2 |
| 228 |
--source include/rpl_connection.inc |
| 229 |
SET GLOBAL debug = @original_debug; |
| 230 |
SET DEBUG_SYNC= 'now SIGNAL continue'; |
| 231 |
|
| 232 |
--let $rpl_connection_name= server_3 |
| 233 |
--source include/rpl_connection.inc |
| 234 |
SET GLOBAL debug = @original_debug; |
| 235 |
SET DEBUG_SYNC= 'now SIGNAL continue'; |
| 236 |
|
| 237 |
--let $rpl_connection_name= server_4 |
| 238 |
--source include/rpl_connection.inc |
| 239 |
SET GLOBAL debug = @original_debug; |
| 240 |
SET DEBUG_SYNC= 'now SIGNAL continue'; |
| 241 |
|
| 242 |
--let $rpl_connection_name= default |
| 243 |
--source include/rpl_connection.inc |
| 244 |
--reap |
| 245 |
--let $semi_sync_yes_tx_increment= 1 |
| 246 |
--source include/assert_semisync_yesno_tx_increment.inc |
| 247 |
|
| 248 |
--echo ###################################################################### |
| 249 |
--echo # Test Case: Verify it can work well when number of semisync slaves |
| 250 |
--echo # is greater than rpl_semi_sync_source_wait_for_replica_count |
| 251 |
--echo ###################################################################### |
| 252 |
--let $rpl_connection_name= server_1 |
| 253 |
--source include/rpl_connection.inc |
| 254 |
SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = 2; |
| 255 |
|
| 256 |
--source include/save_semisync_yesno_tx.inc |
| 257 |
INSERT INTO t1 VALUES(106); |
| 258 |
INSERT INTO t1 VALUES(107); |
| 259 |
# It guarantees semisync master get acks from all slaves. |
| 260 |
--source include/rpl_sync.inc |
| 261 |
|
| 262 |
--let $semi_sync_yes_tx_increment= 2 |
| 263 |
--source include/assert_semisync_yesno_tx_increment.inc |
| 264 |
|
| 265 |
SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = 4; |
| 266 |
--source include/save_semisync_yesno_tx.inc |
| 267 |
INSERT INTO t1 VALUES(108); |
| 268 |
INSERT INTO t1 VALUES(109); |
| 269 |
--let $semi_sync_yes_tx_increment= 2 |
| 270 |
--source include/assert_semisync_yesno_tx_increment.inc |
| 271 |
|
| 272 |
--echo ###################################################################### |
| 273 |
--echo # Test Case: It should still keep the old value and works well when |
| 274 |
--echo # setting rpl_semi_sync_source_wait_for_replica_count fails |
| 275 |
--echo ###################################################################### |
| 276 |
SET @original_debug = @@GLOBAL.debug; |
| 277 |
SET GLOBAL debug = '+d,rpl_semisync_simulate_allocate_ack_container_failure'; |
| 278 |
|
| 279 |
SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = 2; |
| 280 |
--let $assert_variable_name= rpl_semi_sync_source_wait_for_replica_count |
| 281 |
--let $assert_variable_value= 4 |
| 282 |
--source include/assert_variable.inc |
| 283 |
|
| 284 |
--source include/save_semisync_yesno_tx.inc |
| 285 |
INSERT INTO t1 VALUES(110); |
| 286 |
INSERT INTO t1 VALUES(111); |
| 287 |
|
| 288 |
--let $semi_sync_yes_tx_increment= 2 |
| 289 |
--source include/assert_semisync_yesno_tx_increment.inc |
| 290 |
|
| 291 |
SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = 5; |
| 292 |
--let $assert_variable_name= rpl_semi_sync_source_wait_for_replica_count |
| 293 |
--let $assert_variable_value= 4 |
| 294 |
--source include/assert_variable.inc |
| 295 |
|
| 296 |
--source include/save_semisync_yesno_tx.inc |
| 297 |
INSERT INTO t1 VALUES(112); |
| 298 |
INSERT INTO t1 VALUES(113); |
| 299 |
|
| 300 |
--let $semi_sync_yes_tx_increment= 2 |
| 301 |
--source include/assert_semisync_yesno_tx_increment.inc |
| 302 |
|
| 303 |
SET GLOBAL debug = @original_debug; |
| 304 |
|
| 305 |
--echo ######################################################################## |
| 306 |
--echo # Test Case: Verify it works well when some semisync slaves shutdown and |
| 307 |
--echo # rpl_semi_sync_source_wait_for_replica_count is decreased. |
| 308 |
--echo ######################################################################## |
| 309 |
# This test requires semisync master is till on, even if it doesn't |
| 310 |
# have enough slaves |
| 311 |
SET GLOBAL rpl_semi_sync_source_wait_no_replica = 1; |
| 312 |
|
| 313 |
# Transactions sould wait a long time, so they can succeed after |
| 314 |
# rpl_semi_sync_source_wait_no_replica is decreased. |
| 315 |
SET GLOBAL rpl_semi_sync_source_timeout = 90000000; |
| 316 |
|
| 317 |
--let $rpl_connection_name= server_5 |
| 318 |
--source include/rpl_connection.inc |
| 319 |
--source include/uninstall_semisync_replica.inc |
| 320 |
|
| 321 |
--let $rpl_connection_name= server_4 |
| 322 |
--source include/rpl_connection.inc |
| 323 |
--source include/uninstall_semisync_replica.inc |
| 324 |
|
| 325 |
--let $rpl_connection_name= default |
| 326 |
--source include/rpl_connection.inc |
| 327 |
|
| 328 |
--source include/save_semisync_yesno_tx.inc |
| 329 |
--send INSERT INTO t1 VALUES(201) |
| 330 |
|
| 331 |
--let $rpl_connection_name= server_1 |
| 332 |
--source include/rpl_connection.inc |
| 333 |
# It makes sure that master has received two acks |
| 334 |
--source include/rpl_sync.inc |
| 335 |
|
| 336 |
SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = 2; |
| 337 |
|
| 338 |
--let $rpl_connection_name= default |
| 339 |
--source include/rpl_connection.inc |
| 340 |
--reap |
| 341 |
|
| 342 |
--let $semi_sync_yes_tx_increment= 1 |
| 343 |
--source include/assert_semisync_yesno_tx_increment.inc |
| 344 |
|
| 345 |
--let $rpl_connection_name= server_3 |
| 346 |
--source include/rpl_connection.inc |
| 347 |
--source include/uninstall_semisync_replica.inc |
| 348 |
|
| 349 |
--let $rpl_connection_name= default |
| 350 |
--source include/rpl_connection.inc |
| 351 |
--source include/save_semisync_yesno_tx.inc |
| 352 |
|
| 353 |
--send INSERT INTO t1 VALUES(202) |
| 354 |
|
| 355 |
--let $rpl_connection_name= server_1 |
| 356 |
--source include/rpl_connection.inc |
| 357 |
# It makes sure that master has received one ack |
| 358 |
--source include/rpl_sync.inc |
| 359 |
|
| 360 |
SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = 1; |
| 361 |
|
| 362 |
--let $rpl_connection_name= default |
| 363 |
--source include/rpl_connection.inc |
| 364 |
--reap |
| 365 |
|
| 366 |
--let $semi_sync_yes_tx_increment= 1 |
| 367 |
--source include/assert_semisync_yesno_tx_increment.inc |
| 368 |
|
| 369 |
--echo ######################################################################## |
| 370 |
--echo # Test Case: Verify semisync master will turn off immediately after a |
| 371 |
--echo # a semisync slave unregistered and there are no enough |
| 372 |
--echo # semisync slaves |
| 373 |
--echo ######################################################################## |
| 374 |
SET GLOBAL rpl_semi_sync_source_wait_no_replica = 0; |
| 375 |
|
| 376 |
--let $rpl_connection_name= server_2 |
| 377 |
--source include/rpl_connection.inc |
| 378 |
--source include/uninstall_semisync_replica.inc |
| 379 |
|
| 380 |
--let $rpl_connection_name= server_1 |
| 381 |
--source include/rpl_connection.inc |
| 382 |
--source include/wait_for_semisync_source_status_off.inc |
| 383 |
|
| 384 |
--echo ######################################################################## |
| 385 |
--echo # Coverage Test |
| 386 |
--echo ######################################################################## |
| 387 |
# Nothing is changed if the new value equals to the original value |
| 388 |
SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = 4; |
| 389 |
SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = 4; |
| 390 |
|
| 391 |
# Ack array should be cleaned when disabling semisync master |
| 392 |
SET GLOBAL rpl_semi_sync_source_enabled= OFF; |
| 393 |
SET GLOBAL rpl_semi_sync_source_enabled= OFF; |
| 394 |
SET GLOBAL rpl_semi_sync_source_enabled= ON; |
| 395 |
|
| 396 |
# Ack array should be freed when uninstalling semisync master |
| 397 |
--source include/uninstall_semisync_source.inc |
| 398 |
# end |
| 399 |
|
| 400 |
--let $rpl_connection_name= server_1 |
| 401 |
--source include/rpl_connection.inc |
| 402 |
DROP TABLE t1; |
| 403 |
CALL mtr.add_suppression(".* Timeout waiting for reply of binlog .*"); |
| 404 |
CALL mtr.add_suppression(".* Failed to allocate memory for ack_array .*"); |
| 405 |
--source include/rpl_end.inc |