| 1 |
--source include/have_innodb.inc |
| 2 |
--source include/have_debug_sync.inc |
| 3 |
--source include/master-slave.inc |
| 4 |
|
| 5 |
CALL mtr.add_suppression("Failed to start semi-sync ACK receiver thread.*"); |
| 6 |
CALL mtr.add_suppression("Failed to register slave to semi-sync ACK receiver thread.*"); |
| 7 |
CALL mtr.add_suppression("Failed to stop ack receiver thread on pthread_join.*"); |
| 8 |
CALL mtr.add_suppression("Got an error reading communication packets:*"); |
| 9 |
CALL mtr.add_suppression("Timeout waiting for reply of binlog*"); |
| 10 |
CALL mtr.add_suppression("slave_read_sync_header*"); |
| 11 |
CALL mtr.add_suppression("Missing magic number for semi-sync*"); |
| 12 |
CALL mtr.add_suppression("Got timeout reading communication packets*"); |
| 13 |
CALL mtr.add_suppression("Failed to call*"); |
| 14 |
CALL mtr.add_suppression("Execution failed on master*"); |
| 15 |
CALL mtr.add_suppression("Failed on request_dump()*"); |
| 16 |
CALL mtr.add_suppression("Semi-sync master failed on*"); |
| 17 |
CALL mtr.add_suppression("Master command COM_BINLOG_DUMP failed*"); |
| 18 |
CALL mtr.add_suppression("on master failed*"); |
| 19 |
CALL mtr.add_suppression("Semi-sync slave net_flush*"); |
| 20 |
CALL mtr.add_suppression("Failed to flush master info*"); |
| 21 |
CALL mtr.add_suppression("Request to stop slave SQL Thread received while apply*"); |
| 22 |
|
| 23 |
connection master; |
| 24 |
echo [ enable semi-sync on master ]; |
| 25 |
set global rpl_semi_sync_master_enabled = 1; |
| 26 |
show variables like 'rpl_semi_sync_master_enabled'; |
| 27 |
|
| 28 |
connection slave; |
| 29 |
echo [ enable semi-sync on slave ]; |
| 30 |
stop slave; |
| 31 |
set global rpl_semi_sync_slave_enabled = 1; |
| 32 |
start slave; |
| 33 |
let $status_var= rpl_semi_sync_slave_status; |
| 34 |
let $status_var_value= ON; |
| 35 |
source include/wait_for_status_var.inc; |
| 36 |
show status like 'rpl_semi_sync_slave%'; |
| 37 |
|
| 38 |
|
| 39 |
connection master; |
| 40 |
CREATE TABLE t1(a INT) ENGINE=InnoDB; |
| 41 |
sync_slave_with_master; |
| 42 |
|
| 43 |
connection master; |
| 44 |
connect(con1,localhost,root,,); |
| 45 |
connect(con2,localhost,root,,); |
| 46 |
connect(con3,localhost,root,,); |
| 47 |
|
| 48 |
show status like 'Rpl_semi_sync_master_clients'; |
| 49 |
show status like "rpl_semi_sync_master_yes_tx"; |
| 50 |
|
| 51 |
--echo ######################################### |
| 52 |
--echo # Test rpl_semi_sync_master_wait_point # |
| 53 |
--echo ######################################### |
| 54 |
--echo # Test after_sync and after_commit first. |
| 55 |
|
| 56 |
--echo #Test after_sync |
| 57 |
connection con1; |
| 58 |
# Let's set a very large timeout value for testing purpose. |
| 59 |
SET GLOBAL rpl_semi_sync_master_timeout = 1000000; |
| 60 |
SET GLOBAL rpl_semi_sync_master_wait_point= 'AFTER_SYNC'; |
| 61 |
SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL after_sync_done WAIT_FOR end"; |
| 62 |
--send INSERT into t1 values (1); |
| 63 |
|
| 64 |
connection con2; |
| 65 |
SET DEBUG_SYNC= "now WAIT_FOR after_sync_done"; |
| 66 |
|
| 67 |
sync_slave_with_master; |
| 68 |
--echo #slave can see record (1) after sync slave with master |
| 69 |
select * from t1; |
| 70 |
|
| 71 |
connection con2; |
| 72 |
--echo #con2 shouldn't see record (1) |
| 73 |
select * from t1; |
| 74 |
SET DEBUG_SYNC= "now SIGNAL end"; |
| 75 |
|
| 76 |
connection con1; |
| 77 |
reap; |
| 78 |
|
| 79 |
connection con1; |
| 80 |
select * from t1; |
| 81 |
truncate table t1; |
| 82 |
|
| 83 |
# MDEV-515 takes X-lock on the table |
| 84 |
# So concurrent DML won't happen on the table |
| 85 |
INSERT INTO t1 VALUES (100); |
| 86 |
|
| 87 |
sync_slave_with_master; |
| 88 |
|
| 89 |
# Test more threads in one semisync queue |
| 90 |
connection con1; |
| 91 |
SET DEBUG_SYNC= 'reset'; |
| 92 |
SET DEBUG_SYNC= "commit_before_get_LOCK_log SIGNAL before_fetch_done WAIT_FOR more_queue"; |
| 93 |
#SET DEBUG_SYNC= "before_semisync_fetch SIGNAL before_fetch_done WAIT_FOR more_queue"; |
| 94 |
--send INSERT into t1 VALUES (1); |
| 95 |
|
| 96 |
connection con2; |
| 97 |
SET DEBUG_SYNC= "now WAIT_FOR before_fetch_done"; |
| 98 |
SET DEBUG_SYNC= "after_semisync_queue SIGNAL more_queue"; |
| 99 |
INSERT INTO t1 VALUES (2); |
| 100 |
|
| 101 |
connection con1; |
| 102 |
reap; |
| 103 |
|
| 104 |
# Test more threads in one semisync queue, but disable semisync before |
| 105 |
# waiting. |
| 106 |
connection con1; |
| 107 |
SET DEBUG_SYNC= 'reset'; |
| 108 |
SET DEBUG_SYNC= "commit_before_get_LOCK_log SIGNAL before_fetch_done WAIT_FOR disable_semisync"; |
| 109 |
#SET DEBUG_SYNC= "before_semisync_fetch SIGNAL before_fetch_done WAIT_FOR more_queue"; |
| 110 |
#SET DEBUG_SYNC= "before_semisync_fetch SIGNAL before_fetch_done WAIT_FOR disable_semisync"; |
| 111 |
--send INSERT into t1 VALUES (3); |
| 112 |
|
| 113 |
connection con2; |
| 114 |
SET DEBUG_SYNC= "now WAIT_FOR before_fetch_done"; |
| 115 |
SET GLOBAL rpl_semi_sync_master_enabled= 0; |
| 116 |
SET DEBUG_SYNC= "now SIGNAL disable_semisync"; |
| 117 |
|
| 118 |
connection con1; |
| 119 |
reap; |
| 120 |
SET GLOBAL rpl_semi_sync_master_enabled = 1; |
| 121 |
show status like 'Rpl_semi_sync_master_clients'; |
| 122 |
|
| 123 |
--echo #Test after_commit |
| 124 |
connection con1; |
| 125 |
SET GLOBAL rpl_semi_sync_master_wait_point= 'AFTER_COMMIT'; |
| 126 |
SET DEBUG_SYNC= "after_group_after_commit SIGNAL after_commit_done WAIT_FOR end"; |
| 127 |
--send INSERT into t1 values (4); |
| 128 |
|
| 129 |
connection con2; |
| 130 |
SET DEBUG_SYNC= "now WAIT_FOR after_commit_done"; |
| 131 |
|
| 132 |
sync_slave_with_master; |
| 133 |
select * from t1; |
| 134 |
|
| 135 |
connection con2; |
| 136 |
select * from t1; |
| 137 |
SET DEBUG_SYNC= "now SIGNAL end"; |
| 138 |
|
| 139 |
connection con1; |
| 140 |
reap; |
| 141 |
|
| 142 |
connection con1; |
| 143 |
select * from t1; |
| 144 |
truncate table t1; |
| 145 |
|
| 146 |
--echo ####################################################### |
| 147 |
--echo # Test some other options in order to cover the patch # |
| 148 |
--echo ####################################################### |
| 149 |
connection slave; |
| 150 |
--echo # Test rpl_semi_sync_slave_trace_level |
| 151 |
SET GLOBAL rpl_semi_sync_slave_trace_level= 1; |
| 152 |
SET GLOBAL rpl_semi_sync_slave_trace_level= 16; |
| 153 |
SET GLOBAL rpl_semi_sync_slave_trace_level= 64; |
| 154 |
SET GLOBAL rpl_semi_sync_slave_trace_level= 128; |
| 155 |
SET GLOBAL rpl_semi_sync_slave_trace_level= 32; |
| 156 |
connection master; |
| 157 |
--echo # Test rpl_semi_sync_master_trace_level |
| 158 |
SET GLOBAL rpl_semi_sync_master_trace_level= 1; |
| 159 |
SET GLOBAL rpl_semi_sync_master_trace_level= 16; |
| 160 |
SET GLOBAL rpl_semi_sync_master_trace_level= 64; |
| 161 |
SET GLOBAL rpl_semi_sync_master_trace_level= 128; |
| 162 |
SET GLOBAL rpl_semi_sync_master_trace_level= 32; |
| 163 |
--echo # Test rpl_semi_sync_master_timeout |
| 164 |
SET GLOBAL rpl_semi_sync_master_timeout= 1000; |
| 165 |
SET GLOBAL rpl_semi_sync_master_timeout= 10000; |
| 166 |
SET GLOBAL rpl_semi_sync_master_timeout = 1000000; |
| 167 |
|
| 168 |
--echo # Test rpl_semi_sync_slave_kill_conn_timeout |
| 169 |
SET GLOBAL rpl_semi_sync_slave_kill_conn_timeout= 10; |
| 170 |
SET GLOBAL rpl_semi_sync_slave_kill_conn_timeout= 20; |
| 171 |
SET GLOBAL rpl_semi_sync_slave_kill_conn_timeout= 60; |
| 172 |
SET GLOBAL rpl_semi_sync_slave_kill_conn_timeout= 5; |
| 173 |
|
| 174 |
--echo ############################################ |
| 175 |
--echo # Test rpl_semi_sync_master_wait_no_slave # |
| 176 |
--echo ############################################ |
| 177 |
SET GLOBAL rpl_semi_sync_master_wait_no_slave = 1; |
| 178 |
connection slave; |
| 179 |
STOP SLAVE IO_THREAD; |
| 180 |
--source include/wait_for_slave_io_to_stop.inc |
| 181 |
|
| 182 |
connection con1; |
| 183 |
SET GLOBAL rpl_semi_sync_master_timeout = 1000; |
| 184 |
--send INSERT INTO t1 values (1); |
| 185 |
|
| 186 |
connection con1; |
| 187 |
reap; |
| 188 |
echo # Rpl_semi_sync_master_no_tx should be non-zero |
| 189 |
SHOW STATUS LIKE 'Rpl_semi_sync_master_no_tx'; |
| 190 |
|
| 191 |
# test rpl_semi_sync_master_wait_no_slave = 0 |
| 192 |
connection slave; |
| 193 |
START SLAVE IO_THREAD; |
| 194 |
--source include/wait_for_slave_io_to_start.inc |
| 195 |
|
| 196 |
connection con1; |
| 197 |
INSERT INTO t1 values (2); |
| 198 |
sync_slave_with_master; |
| 199 |
connection con1; |
| 200 |
let $status_var= Rpl_semi_sync_master_clients; |
| 201 |
let $status_var_value= 1; |
| 202 |
source include/wait_for_status_var.inc; |
| 203 |
let $status_var= Rpl_semi_sync_master_status; |
| 204 |
let $status_var_value= ON; |
| 205 |
source include/wait_for_status_var.inc; |
| 206 |
show status like 'Rpl_semi_sync_master_clients'; |
| 207 |
show status like 'Rpl_semi_sync_master_status'; |
| 208 |
|
| 209 |
connection slave; |
| 210 |
STOP SLAVE IO_THREAD; |
| 211 |
--source include/wait_for_slave_io_to_stop.inc |
| 212 |
|
| 213 |
connection con1; |
| 214 |
SET GLOBAL rpl_semi_sync_master_wait_no_slave= 0; |
| 215 |
SET GLOBAL rpl_semi_sync_master_timeout= 1000000000; |
| 216 |
INSERT INTO t1 values (3); |
| 217 |
show status like 'Rpl_semi_sync_master_clients'; |
| 218 |
show status like 'Rpl_semi_sync_master_status'; |
| 219 |
|
| 220 |
|
| 221 |
connection slave; |
| 222 |
START SLAVE IO_THREAD; |
| 223 |
--source include/wait_for_slave_io_to_start.inc |
| 224 |
|
| 225 |
connection con1; |
| 226 |
--let $status_var= Rpl_semi_sync_master_status |
| 227 |
--let $status_var_value=ON |
| 228 |
--source include/wait_for_status_var.inc |
| 229 |
|
| 230 |
SET GLOBAL rpl_semi_sync_master_timeout= 10000000; |
| 231 |
SET GLOBAL rpl_semi_sync_master_wait_no_slave= 1; |
| 232 |
INSERT INTO t1 values (4); |
| 233 |
sync_slave_with_master; |
| 234 |
|
| 235 |
connection con1; |
| 236 |
show status like 'Rpl_semi_sync_master_status'; |
| 237 |
show status like 'Rpl_semi_sync_master_clients'; |
| 238 |
|
| 239 |
--echo ########################################## |
| 240 |
--echo # Test rpl_semi_sync_slave_delay_master # |
| 241 |
--echo ########################################## |
| 242 |
|
| 243 |
connection slave; |
| 244 |
SET GLOBAL rpl_semi_sync_slave_delay_master= 1; |
| 245 |
START SLAVE IO_THREAD; |
| 246 |
--source include/wait_for_slave_io_to_start.inc |
| 247 |
|
| 248 |
connection con1; |
| 249 |
INSERT INTO t1 values (3); |
| 250 |
--source include/sync_slave_io_with_master.inc |
| 251 |
|
| 252 |
connection con1; |
| 253 |
show status like 'Rpl_semi_sync_master_clients'; |
| 254 |
show status like 'Rpl_semi_sync_master_status'; |
| 255 |
|
| 256 |
sync_slave_with_master; |
| 257 |
|
| 258 |
connection slave; |
| 259 |
select * from t1 order by a; |
| 260 |
connection con1; |
| 261 |
select * from t1 order by a; |
| 262 |
|
| 263 |
connection slave; |
| 264 |
SET GLOBAL rpl_semi_sync_slave_delay_master = 0; |
| 265 |
STOP SLAVE IO_THREAD; |
| 266 |
--source include/wait_for_slave_io_to_stop.inc |
| 267 |
START SLAVE IO_THREAD; |
| 268 |
--source include/wait_for_slave_io_to_start.inc |
| 269 |
|
| 270 |
--echo ########################################################## |
| 271 |
--echo # Test rpl_semi_sync_master_enabled and new ACK thread # |
| 272 |
--echo ######################################################### |
| 273 |
connection con1; |
| 274 |
SET GLOBAL rpl_semi_sync_master_enabled = 0; |
| 275 |
|
| 276 |
let $status_var= Rpl_semi_sync_master_clients; |
| 277 |
let $status_var_value= 1; |
| 278 |
source include/wait_for_status_var.inc; |
| 279 |
show status like 'Rpl_semi_sync_master_clients'; |
| 280 |
|
| 281 |
INSERT INTO t1 VALUES (1); |
| 282 |
SET GLOBAL rpl_semi_sync_master_enabled = 1; |
| 283 |
INSERT INTO t1 VALUES (2); |
| 284 |
show status like 'Rpl_semi_sync_master_clients'; |
| 285 |
|
| 286 |
--echo # Test failure of select error . |
| 287 |
SET GLOBAL debug_dbug = 'd,rpl_semisync_simulate_select_error'; |
| 288 |
# It can still receive ACK from semi-sync slave |
| 289 |
INSERT INTO t1 VALUES(3); |
| 290 |
sync_slave_with_master; |
| 291 |
|
| 292 |
connection con1; |
| 293 |
--echo # Test failure of pthread_create |
| 294 |
SET GLOBAL rpl_semi_sync_master_enabled = 0; |
| 295 |
SET GLOBAL debug_dbug = 'd,rpl_semisync_simulate_create_thread_failure'; |
| 296 |
SET GLOBAL rpl_semi_sync_master_enabled= ON; |
| 297 |
|
| 298 |
--let $wait_condition= SELECT @@global.rpl_semi_sync_master_enabled = 0 |
| 299 |
--source include/wait_condition.inc |
| 300 |
|
| 301 |
# Todo: implement the thread join failure simulation |
| 302 |
--echo # Test failure of pthread_join |
| 303 |
#SET GLOBAL DEBUG_DBUG = 'd,rpl_semisync_simulate_thread_join_failure'; |
| 304 |
#SET GLOBAL rpl_semi_sync_master_enabled= ON; |
| 305 |
# |
| 306 |
#--let $wait_condition= SELECT @@global.rpl_semi_sync_master_enabled = 0 |
| 307 |
#--source include/wait_condition.inc |
| 308 |
SET GLOBAL rpl_semi_sync_master_enabled= OFF; |
| 309 |
|
| 310 |
--echo # |
| 311 |
--echo # Failure on registering semisync slave |
| 312 |
--echo # |
| 313 |
SET GLOBAL debug_dbug= 'd,rpl_semisync_simulate_add_slave_failure'; |
| 314 |
SET GLOBAL rpl_semi_sync_master_enabled= ON; |
| 315 |
|
| 316 |
connection slave; |
| 317 |
STOP SLAVE IO_THREAD; |
| 318 |
--source include/wait_for_slave_io_to_stop.inc |
| 319 |
START SLAVE IO_THREAD; |
| 320 |
--source include/wait_for_slave_io_to_start.inc |
| 321 |
|
| 322 |
connection con1; |
| 323 |
#--echo # Should be Zero. |
| 324 |
# Todo: implement the add_slave_failure simulation. Meanwhile |
| 325 |
# the status will be 1. |
| 326 |
# show status like 'Rpl_semi_sync_master_clients'; |
| 327 |
SET GLOBAL debug_dbug=''; |
| 328 |
|
| 329 |
--let $status_var= Rpl_semi_sync_master_clients |
| 330 |
--let $status_var_value= 1 |
| 331 |
--let $status_type= GLOBAL |
| 332 |
--source include/wait_for_status_var.inc |
| 333 |
|
| 334 |
connection slave; |
| 335 |
--disable_warnings |
| 336 |
START SLAVE IO_THREAD; |
| 337 |
--source include/wait_for_slave_io_to_start.inc |
| 338 |
--enable_warnings |
| 339 |
|
| 340 |
connection con1; |
| 341 |
sync_slave_with_master; |
| 342 |
|
| 343 |
show status like 'Rpl_semi_sync_master_clients'; |
| 344 |
|
| 345 |
--echo ################################################################## |
| 346 |
--echo # Test fixing of BUG#70669 # |
| 347 |
--echo #SLAVE CAN'T CONTINUE REPLICATION AFTER MASTER'S CRASH RECOVERY # |
| 348 |
--echo ################################################################# |
| 349 |
connection con1; |
| 350 |
SET GLOBAL sync_binlog = 1; |
| 351 |
CREATE TABLE t2 (c1 INT); |
| 352 |
sync_slave_with_master; |
| 353 |
|
| 354 |
connection con1; |
| 355 |
# Block the session before its events are synced to disk |
| 356 |
#SET DEBUG_SYNC = 'before_sync_binlog_file SIGNAL before_sync_done WAIT_FOR continue'; |
| 357 |
send INSERT INTO t2 values (1); |
| 358 |
|
| 359 |
connection slave; |
| 360 |
--let $table= t2 |
| 361 |
--let $count= 1 |
| 362 |
--source include/wait_until_rows_count.inc |
| 363 |
|
| 364 |
connection con2; |
| 365 |
#SET DEBUG_SYNC= "now WAIT_FOR before_sync_done"; |
| 366 |
#SET DEBUG_SYNC = "now SIGNAL continue"; |
| 367 |
|
| 368 |
connection con1; |
| 369 |
reap; |
| 370 |
|
| 371 |
sync_slave_with_master; |
| 372 |
show tables like 't2'; |
| 373 |
select * from t2; |
| 374 |
|
| 375 |
connection con1; |
| 376 |
#SET DEBUG_SYNC= "before_update_pos SIGNAL leader_ready WAIT_FOR follower_ready"; |
| 377 |
send INSERT INTO t2 VALUES (2); |
| 378 |
|
| 379 |
connection con2; |
| 380 |
#SET DEBUG_SYNC= "now WAIT_FOR leader_ready"; |
| 381 |
#SET DEBUG_SYNC= "after_sync_queue SIGNAL follower_ready"; |
| 382 |
send INSERT INTO t2 VALUES (3); |
| 383 |
|
| 384 |
connection con1; |
| 385 |
reap; |
| 386 |
connection con2; |
| 387 |
reap; |
| 388 |
|
| 389 |
connection con1; |
| 390 |
#SET DEBUG_SYNC = 'before_sync_binlog_file SIGNAL before_sync_done WAIT_FOR continue'; |
| 391 |
SET GLOBAL sync_binlog = 0; |
| 392 |
|
| 393 |
# Todo: fix this simulation and implement the intended sync protocol. |
| 394 |
# As a workaround the DROP sender explicitly okays |
| 395 |
# which naturally increments the binlog position. |
| 396 |
#send DROP TABLE t2; |
| 397 |
DROP TABLE t2; |
| 398 |
|
| 399 |
connection con2; |
| 400 |
#SET DEBUG_SYNC= "now WAIT_FOR before_sync_done"; |
| 401 |
|
| 402 |
sync_slave_with_master; |
| 403 |
|
| 404 |
# t2 should be dropped |
| 405 |
show tables like 't2'; |
| 406 |
|
| 407 |
connection con2; |
| 408 |
#SET DEBUG_SYNC = "now SIGNAL continue"; |
| 409 |
|
| 410 |
# This block is commented out on purpose. See the todo/workaround above. |
| 411 |
#connection con1; |
| 412 |
#reap; |
| 413 |
|
| 414 |
|
| 415 |
--echo #cleanup |
| 416 |
connection master; |
| 417 |
SET DEBUG_SYNC= 'reset'; |
| 418 |
disconnect con1; |
| 419 |
disconnect con2; |
| 420 |
disconnect con3; |
| 421 |
SET GLOBAL rpl_semi_sync_master_timeout= 10000; |
| 422 |
SET GLOBAL rpl_semi_sync_master_enabled = 0; |
| 423 |
DROP TABLE t1; |
| 424 |
connection slave; |
| 425 |
SET GLOBAL rpl_semi_sync_slave_enabled = 0; |
| 426 |
|
| 427 |
--source include/rpl_end.inc |