1# 2# Preparation 3# 4CREATE TABLE t1 (i INT NOT NULL, PRIMARY KEY (i)) ENGINE=InnoDB; 5RESET MASTER; 6SET @@global.rpl_semi_sync_master_timeout = 60000; 7SET @@global.rpl_semi_sync_master_wait_no_slave = 1; 8# It's okay to see "Killed" but we should not see "Timeout" in the log. 9call mtr.add_suppression("Killed waiting for reply of binlog"); 10call mtr.add_suppression("Run function 'after_commit' in plugin 'rpl_semi_sync_master' failed"); 11call mtr.add_suppression("Run function 'after_sync' in plugin 'rpl_semi_sync_master' failed"); 12# 13# Test wait point = AFTER_COMMIT 14# 15SET @@global.rpl_semi_sync_master_wait_point = AFTER_COMMIT; 16# Make another connection to INSERT from. 17connect other,localhost,root,,; 18connection other; 19connection default; 20SET GLOBAL rpl_semi_sync_master_enabled = 1; 21# Go ahead and send the INSERT; it should block. 22connection other; 23INSERT INTO t1 (i) VALUES (1); 24connection default; 25# The INSERT thread should now be waiting. 26SELECT state AS should_be_waiting 27FROM information_schema.processlist WHERE id = @other_connection_id; 28should_be_waiting 29Waiting for semi-sync ACK from slave 30# The insert should be visible to other threads 31SELECT * FROM t1 ORDER BY 1; 32i 331 34# Kill the waiting thread; it should die immediately. 35KILL @other_connection_id; 36# Collect the error from the INSERT thread; it should be disconnected. 37connection other; 38Got one of the listed errors 39connection default; 40# Wait for INSERT thread to actually disappear (KILL closes connection 41# before thread actually finishes its processing). 42# The INSERT thread should now be gone. 43SELECT state AS should_be_empty_set 44FROM information_schema.processlist WHERE id = @other_connection_id; 45should_be_empty_set 46# The insert is still there 47SELECT * FROM t1 ORDER BY 1; 48i 491 50connection default; 51disconnect other; 52# Make another connection to INSERT from. 53connect other,localhost,root,,; 54connection other; 55connection default; 56# Go ahead and send the INSERT; it should block. 57connection other; 58INSERT INTO t1 (i) VALUES (2); 59connection default; 60# The INSERT thread should now be waiting. 61SELECT state AS should_be_waiting 62FROM information_schema.processlist WHERE id = @other_connection_id; 63should_be_waiting 64Waiting for semi-sync ACK from slave 65# The insert should be visible to other threads 66SELECT * FROM t1 ORDER BY 1; 67i 681 692 70# Now restart server 71# restart 72# Done restarting server 73# Reset setting that were lost in restart 74SET @@global.rpl_semi_sync_master_timeout = 60000; 75SET @@global.rpl_semi_sync_master_wait_no_slave = 1; 76# Check that row is still there 77SELECT * FROM t1 ORDER BY 1; 78i 791 802 81disconnect other; 82# 83# Test wait point = AFTER_SYNC 84# 85SET @@global.rpl_semi_sync_master_wait_point = AFTER_SYNC; 86# Make another connection to INSERT from. 87connect other,localhost,root,,; 88connection other; 89connection default; 90SET GLOBAL rpl_semi_sync_master_enabled = 1; 91# Go ahead and send the INSERT; it should block. 92connection other; 93INSERT INTO t1 (i) VALUES (3); 94connection default; 95# The INSERT thread should now be waiting. 96SELECT state AS should_be_waiting 97FROM information_schema.processlist WHERE id = @other_connection_id; 98should_be_waiting 99Waiting for semi-sync ACK from slave 100# The insert should NOT be visible to other threads 101SELECT * FROM t1 ORDER BY 1; 102i 1031 1042 105# Kill the waiting thread; it should die immediately. 106KILL @other_connection_id; 107# Collect the error from the INSERT thread; it should be disconnected. 108connection other; 109Got one of the listed errors 110connection default; 111# Wait for INSERT thread to actually disappear (KILL closes connection 112# before thread actually finishes its processing). 113# The INSERT thread should now be gone. 114SELECT state AS should_be_empty_set 115FROM information_schema.processlist WHERE id = @other_connection_id; 116should_be_empty_set 117# The row inserted is there 118SELECT * FROM t1 ORDER BY 1; 119i 1201 1212 1223 123connection default; 124disconnect other; 125# Make another connection to INSERT from. 126connect other,localhost,root,,; 127connection other; 128connection default; 129# Go ahead and send the INSERT; it should block. 130connection other; 131INSERT INTO t1 (i) VALUES (4); 132connection default; 133# The INSERT thread should now be waiting. 134SELECT state AS should_be_waiting 135FROM information_schema.processlist WHERE id = @other_connection_id; 136should_be_waiting 137Waiting for semi-sync ACK from slave 138# The insert should NOT be visible to other threads 139SELECT * FROM t1 ORDER BY 1; 140i 1411 1422 1433 144# Now restart server 145# restart 146# Done restarting server 147# Reset setting that were lost in restart 148SET @@global.rpl_semi_sync_master_timeout = 60000; 149SET @@global.rpl_semi_sync_master_wait_no_slave = 1; 150# But the row inserted is there 151SELECT * FROM t1 ORDER BY 1; 152i 1531 1542 1553 1564 157disconnect other; 158# 159# Cleanup 160# 161SET GLOBAL rpl_semi_sync_master_enabled = 0; 162DROP TABLE t1; 163SET @@global.rpl_semi_sync_master_timeout = 10000; 164SET @@global.rpl_semi_sync_master_wait_no_slave = 1; 165SET @@global.rpl_semi_sync_master_wait_point = AFTER_COMMIT; 166