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