| 1 |
source include/not_embedded.inc; |
| 2 |
source include/have_innodb.inc; |
| 3 |
|
| 4 |
# |
| 5 |
# This test the rpl_semi_sync_master_wait_point functionality |
| 6 |
# and illustrates the differences between the two values AFTER_COMMIT and |
| 7 |
# AFTER_SYNC |
| 8 |
# |
| 9 |
|
| 10 |
--echo # |
| 11 |
--echo # Preparation |
| 12 |
--echo # |
| 13 |
|
| 14 |
CREATE TABLE t1 (i INT NOT NULL, PRIMARY KEY (i)) ENGINE=InnoDB; |
| 15 |
RESET MASTER; |
| 16 |
|
| 17 |
let $save_timeout = `select @@global.rpl_semi_sync_master_timeout`; |
| 18 |
let $save_wait_no_slave = `select @@global.rpl_semi_sync_master_wait_no_slave`; |
| 19 |
let $save_wait_point = `select @@global.rpl_semi_sync_master_wait_point`; |
| 20 |
|
| 21 |
SET @@global.rpl_semi_sync_master_timeout = 60000; |
| 22 |
SET @@global.rpl_semi_sync_master_wait_no_slave = 1; |
| 23 |
|
| 24 |
--echo # It's okay to see "Killed" but we should not see "Timeout" in the log. |
| 25 |
call mtr.add_suppression("Killed waiting for reply of binlog"); |
| 26 |
|
| 27 |
--echo # |
| 28 |
--echo # Test wait point = AFTER_COMMIT |
| 29 |
--echo # |
| 30 |
SET @@global.rpl_semi_sync_master_wait_point = AFTER_COMMIT; |
| 31 |
|
| 32 |
--echo # Make another connection to INSERT from. |
| 33 |
connect (other,localhost,root,,); |
| 34 |
connection other; |
| 35 |
let $other_connection_id = `SELECT CONNECTION_ID()`; |
| 36 |
|
| 37 |
connection default; |
| 38 |
|
| 39 |
--disable_query_log |
| 40 |
eval SET @other_connection_id = $other_connection_id; |
| 41 |
--enable_query_log |
| 42 |
|
| 43 |
SET GLOBAL rpl_semi_sync_master_enabled = 1; |
| 44 |
|
| 45 |
--echo # Go ahead and send the INSERT; it should block. |
| 46 |
connection other; |
| 47 |
send INSERT INTO t1 (i) VALUES (1); |
| 48 |
|
| 49 |
connection default; |
| 50 |
|
| 51 |
let $wait_condition = |
| 52 |
SELECT COUNT(*) > 0 AS should_be_true |
| 53 |
FROM information_schema.processlist |
| 54 |
WHERE id = @other_connection_id |
| 55 |
AND state = "Waiting for semi-sync ACK from slave"; |
| 56 |
--source include/wait_condition.inc |
| 57 |
|
| 58 |
--echo # 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 |
|
| 62 |
--echo # The insert should be visible to other threads |
| 63 |
SELECT * FROM t1 ORDER BY 1; |
| 64 |
|
| 65 |
--echo # Kill the waiting thread; it should die immediately. |
| 66 |
KILL @other_connection_id; |
| 67 |
|
| 68 |
--echo # Collect the error from the INSERT thread; it should be disconnected. |
| 69 |
connection other; |
| 70 |
--error 2013,ER_CONNECTION_KILLED |
| 71 |
reap; |
| 72 |
|
| 73 |
connection default; |
| 74 |
|
| 75 |
--echo # Wait for INSERT thread to actually disappear (KILL closes connection |
| 76 |
--echo # before thread actually finishes its processing). |
| 77 |
let $wait_condition = |
| 78 |
SELECT COUNT(*) = 0 AS should_be_true |
| 79 |
FROM information_schema.processlist |
| 80 |
WHERE id = @other_connection_id; |
| 81 |
--source include/wait_condition.inc |
| 82 |
|
| 83 |
--echo # The INSERT thread should now be gone. |
| 84 |
SELECT state AS should_be_empty_set |
| 85 |
FROM information_schema.processlist WHERE id = @other_connection_id; |
| 86 |
|
| 87 |
--echo # The insert is still there |
| 88 |
SELECT * FROM t1 ORDER BY 1; |
| 89 |
|
| 90 |
connection default; |
| 91 |
disconnect other; |
| 92 |
|
| 93 |
--echo # Make another connection to INSERT from. |
| 94 |
connect (other,localhost,root,,); |
| 95 |
connection other; |
| 96 |
let $other_connection_id = `SELECT CONNECTION_ID()`; |
| 97 |
connection default; |
| 98 |
--disable_query_log |
| 99 |
eval SET @other_connection_id = $other_connection_id; |
| 100 |
--enable_query_log |
| 101 |
|
| 102 |
--echo # Go ahead and send the INSERT; it should block. |
| 103 |
connection other; |
| 104 |
send INSERT INTO t1 (i) VALUES (2); |
| 105 |
|
| 106 |
connection default; |
| 107 |
|
| 108 |
let $wait_condition = |
| 109 |
SELECT COUNT(*) > 0 AS should_be_true |
| 110 |
FROM information_schema.processlist |
| 111 |
WHERE id = @other_connection_id |
| 112 |
AND state = "Waiting for semi-sync ACK from slave"; |
| 113 |
--source include/wait_condition.inc |
| 114 |
|
| 115 |
--echo # The INSERT thread should now be waiting. |
| 116 |
SELECT state AS should_be_waiting |
| 117 |
FROM information_schema.processlist WHERE id = @other_connection_id; |
| 118 |
|
| 119 |
--echo # The insert should be visible to other threads |
| 120 |
SELECT * FROM t1 ORDER BY 1; |
| 121 |
|
| 122 |
--echo # Now restart server |
| 123 |
--source include/restart_mysqld.inc |
| 124 |
--echo # Done restarting server |
| 125 |
|
| 126 |
--echo # Reset setting that were lost in restart |
| 127 |
SET @@global.rpl_semi_sync_master_timeout = 60000; |
| 128 |
SET @@global.rpl_semi_sync_master_wait_no_slave = 1; |
| 129 |
|
| 130 |
--echo # Check that row is still there |
| 131 |
SELECT * FROM t1 ORDER BY 1; |
| 132 |
|
| 133 |
disconnect other; |
| 134 |
|
| 135 |
--echo # |
| 136 |
--echo # Test wait point = AFTER_SYNC |
| 137 |
--echo # |
| 138 |
SET @@global.rpl_semi_sync_master_wait_point = AFTER_SYNC; |
| 139 |
|
| 140 |
--echo # Make another connection to INSERT from. |
| 141 |
connect (other,localhost,root,,); |
| 142 |
connection other; |
| 143 |
let $other_connection_id = `SELECT CONNECTION_ID()`; |
| 144 |
|
| 145 |
connection default; |
| 146 |
|
| 147 |
--disable_query_log |
| 148 |
eval SET @other_connection_id = $other_connection_id; |
| 149 |
--enable_query_log |
| 150 |
|
| 151 |
SET GLOBAL rpl_semi_sync_master_enabled = 1; |
| 152 |
|
| 153 |
--echo # Go ahead and send the INSERT; it should block. |
| 154 |
connection other; |
| 155 |
send INSERT INTO t1 (i) VALUES (3); |
| 156 |
|
| 157 |
connection default; |
| 158 |
|
| 159 |
let $wait_condition = |
| 160 |
SELECT COUNT(*) > 0 AS should_be_true |
| 161 |
FROM information_schema.processlist |
| 162 |
WHERE id = @other_connection_id |
| 163 |
AND state = "Waiting for semi-sync ACK from slave"; |
| 164 |
--source include/wait_condition.inc |
| 165 |
|
| 166 |
--echo # The INSERT thread should now be waiting. |
| 167 |
SELECT state AS should_be_waiting |
| 168 |
FROM information_schema.processlist WHERE id = @other_connection_id; |
| 169 |
|
| 170 |
--echo # The insert should NOT be visible to other threads |
| 171 |
SELECT * FROM t1 ORDER BY 1; |
| 172 |
|
| 173 |
--echo # Kill the waiting thread; it should die immediately. |
| 174 |
KILL @other_connection_id; |
| 175 |
|
| 176 |
--echo # Collect the error from the INSERT thread; it should be disconnected. |
| 177 |
connection other; |
| 178 |
--error 2013,ER_CONNECTION_KILLED |
| 179 |
reap; |
| 180 |
|
| 181 |
connection default; |
| 182 |
|
| 183 |
--echo # Wait for INSERT thread to actually disappear (KILL closes connection |
| 184 |
--echo # before thread actually finishes its processing). |
| 185 |
let $wait_condition = |
| 186 |
SELECT COUNT(*) = 0 AS should_be_true |
| 187 |
FROM information_schema.processlist |
| 188 |
WHERE id = @other_connection_id; |
| 189 |
--source include/wait_condition.inc |
| 190 |
|
| 191 |
--echo # The INSERT thread should now be gone. |
| 192 |
SELECT state AS should_be_empty_set |
| 193 |
FROM information_schema.processlist WHERE id = @other_connection_id; |
| 194 |
|
| 195 |
--echo # The row inserted is there |
| 196 |
SELECT * FROM t1 ORDER BY 1; |
| 197 |
|
| 198 |
connection default; |
| 199 |
disconnect other; |
| 200 |
|
| 201 |
--echo # Make another connection to INSERT from. |
| 202 |
connect (other,localhost,root,,); |
| 203 |
connection other; |
| 204 |
let $other_connection_id = `SELECT CONNECTION_ID()`; |
| 205 |
connection default; |
| 206 |
--disable_query_log |
| 207 |
eval SET @other_connection_id = $other_connection_id; |
| 208 |
--enable_query_log |
| 209 |
|
| 210 |
--echo # Go ahead and send the INSERT; it should block. |
| 211 |
connection other; |
| 212 |
send INSERT INTO t1 (i) VALUES (4); |
| 213 |
|
| 214 |
connection default; |
| 215 |
|
| 216 |
let $wait_condition = |
| 217 |
SELECT COUNT(*) > 0 AS should_be_true |
| 218 |
FROM information_schema.processlist |
| 219 |
WHERE id = @other_connection_id |
| 220 |
AND state = "Waiting for semi-sync ACK from slave"; |
| 221 |
--source include/wait_condition.inc |
| 222 |
|
| 223 |
--echo # The INSERT thread should now be waiting. |
| 224 |
SELECT state AS should_be_waiting |
| 225 |
FROM information_schema.processlist WHERE id = @other_connection_id; |
| 226 |
|
| 227 |
--echo # The insert should NOT be visible to other threads |
| 228 |
SELECT * FROM t1 ORDER BY 1; |
| 229 |
|
| 230 |
--echo # Now restart server |
| 231 |
--source include/restart_mysqld.inc |
| 232 |
--echo # Done restarting server |
| 233 |
|
| 234 |
--echo # Reset setting that were lost in restart |
| 235 |
SET @@global.rpl_semi_sync_master_timeout = 60000; |
| 236 |
SET @@global.rpl_semi_sync_master_wait_no_slave = 1; |
| 237 |
|
| 238 |
--echo # But the row inserted is there |
| 239 |
SELECT * FROM t1 ORDER BY 1; |
| 240 |
|
| 241 |
disconnect other; |
| 242 |
|
| 243 |
--echo # |
| 244 |
--echo # Cleanup |
| 245 |
--echo # |
| 246 |
SET GLOBAL rpl_semi_sync_master_enabled = 0; |
| 247 |
DROP TABLE t1; |
| 248 |
|
| 249 |
eval SET @@global.rpl_semi_sync_master_timeout = $save_timeout; |
| 250 |
eval SET @@global.rpl_semi_sync_master_wait_no_slave = $save_wait_no_slave; |
| 251 |
eval SET @@global.rpl_semi_sync_master_wait_point = $save_wait_point; |