| 1 |
# |
| 2 |
# Step-1) Initial Setup which is required for the test. |
| 3 |
# |
| 4 |
RESET MASTER; |
| 5 |
# |
| 6 |
# Step-1.1) Create four client connections. |
| 7 |
# |
| 8 |
# |
| 9 |
# Step-1.2) Create a sample table. |
| 10 |
# |
| 11 |
CREATE TABLE t1 (i INT); |
| 12 |
# |
| 13 |
# Step-2) Execute a simple insert transaction that will wait |
| 14 |
# for a signal at various stages of transaction commit. |
| 15 |
# Execute 'RESET MASTER' when it is waiting for the signal |
| 16 |
# and check binlog contents and GTID_EXECUTED (if GTID |
| 17 |
# enabled) that they are as expected. |
| 18 |
# |
| 19 |
[connection conn1] |
| 20 |
BEGIN; |
| 21 |
INSERT INTO t1 VALUES (1); |
| 22 |
SET debug_sync="ha_commit_trans_before_acquire_commit_lock SIGNAL reached WAIT_FOR insert_continue"; |
| 23 |
COMMIT; |
| 24 |
[connection conn2] |
| 25 |
SET debug_sync="now WAIT_FOR reached"; |
| 26 |
RESET MASTER; |
| 27 |
SET debug_sync="now SIGNAL insert_continue"; |
| 28 |
[connection conn1] |
| 29 |
# |
| 30 |
# Step-2.4) Reset the debug signals for the next iteration |
| 31 |
# |
| 32 |
[connection conn2] |
| 33 |
SET debug_sync="RESET"; |
| 34 |
[connection conn1] |
| 35 |
BEGIN; |
| 36 |
INSERT INTO t1 VALUES (1); |
| 37 |
SET debug_sync="bgc_before_flush_stage SIGNAL reached WAIT_FOR insert_continue"; |
| 38 |
COMMIT; |
| 39 |
[connection conn2] |
| 40 |
SET debug_sync="now WAIT_FOR reached"; |
| 41 |
RESET MASTER; |
| 42 |
[connection conn3] |
| 43 |
SET debug_sync="now SIGNAL insert_continue"; |
| 44 |
[connection conn2] |
| 45 |
[connection conn1] |
| 46 |
# |
| 47 |
# Step-2.4) Reset the debug signals for the next iteration |
| 48 |
# |
| 49 |
[connection conn2] |
| 50 |
SET debug_sync="RESET"; |
| 51 |
[connection conn1] |
| 52 |
BEGIN; |
| 53 |
INSERT INTO t1 VALUES (1); |
| 54 |
SET debug_sync="bgc_after_flush_stage_before_sync_stage SIGNAL reached WAIT_FOR insert_continue"; |
| 55 |
COMMIT; |
| 56 |
[connection conn2] |
| 57 |
SET debug_sync="now WAIT_FOR reached"; |
| 58 |
RESET MASTER; |
| 59 |
[connection conn3] |
| 60 |
SET debug_sync="now SIGNAL insert_continue"; |
| 61 |
[connection conn2] |
| 62 |
[connection conn1] |
| 63 |
# |
| 64 |
# Step-2.4) Reset the debug signals for the next iteration |
| 65 |
# |
| 66 |
[connection conn2] |
| 67 |
SET debug_sync="RESET"; |
| 68 |
[connection conn1] |
| 69 |
BEGIN; |
| 70 |
INSERT INTO t1 VALUES (1); |
| 71 |
SET debug_sync="bgc_after_sync_stage_before_commit_stage SIGNAL reached WAIT_FOR insert_continue"; |
| 72 |
COMMIT; |
| 73 |
[connection conn2] |
| 74 |
SET debug_sync="now WAIT_FOR reached"; |
| 75 |
RESET MASTER; |
| 76 |
[connection conn3] |
| 77 |
SET debug_sync="now SIGNAL insert_continue"; |
| 78 |
[connection conn2] |
| 79 |
[connection conn1] |
| 80 |
# |
| 81 |
# Step-2.4) Reset the debug signals for the next iteration |
| 82 |
# |
| 83 |
[connection conn2] |
| 84 |
SET debug_sync="RESET"; |
| 85 |
[connection conn1] |
| 86 |
BEGIN; |
| 87 |
INSERT INTO t1 VALUES (1); |
| 88 |
SET debug_sync="bgc_after_commit_stage_before_rotation SIGNAL reached WAIT_FOR insert_continue"; |
| 89 |
COMMIT; |
| 90 |
[connection conn2] |
| 91 |
SET debug_sync="now WAIT_FOR reached"; |
| 92 |
RESET MASTER; |
| 93 |
[connection conn3] |
| 94 |
SET debug_sync="now SIGNAL insert_continue"; |
| 95 |
[connection conn2] |
| 96 |
[connection conn1] |
| 97 |
# |
| 98 |
# Step-2.4) Reset the debug signals for the next iteration |
| 99 |
# |
| 100 |
[connection conn2] |
| 101 |
SET debug_sync="RESET"; |
| 102 |
[connection conn1] |
| 103 |
BEGIN; |
| 104 |
INSERT INTO t1 VALUES (1); |
| 105 |
SET debug_sync="ha_commit_trans_before_acquire_commit_lock SIGNAL reached WAIT_FOR insert_continue"; |
| 106 |
COMMIT; |
| 107 |
[connection conn2] |
| 108 |
SET debug_sync="now WAIT_FOR reached"; |
| 109 |
FLUSH TABLES WITH READ LOCK; |
| 110 |
SET debug_sync="now SIGNAL insert_continue"; |
| 111 |
RESET MASTER; |
| 112 |
UNLOCK TABLES; |
| 113 |
[connection conn1] |
| 114 |
# |
| 115 |
# Step-2.4) Reset the debug signals for the next iteration |
| 116 |
# |
| 117 |
[connection conn2] |
| 118 |
SET debug_sync="RESET"; |
| 119 |
[connection conn1] |
| 120 |
BEGIN; |
| 121 |
INSERT INTO t1 VALUES (1); |
| 122 |
SET debug_sync="bgc_before_flush_stage SIGNAL reached WAIT_FOR insert_continue"; |
| 123 |
COMMIT; |
| 124 |
[connection conn2] |
| 125 |
SET debug_sync="now WAIT_FOR reached"; |
| 126 |
FLUSH TABLES WITH READ LOCK; |
| 127 |
[connection conn3] |
| 128 |
SET debug_sync="now SIGNAL insert_continue"; |
| 129 |
[connection conn2] |
| 130 |
RESET MASTER; |
| 131 |
UNLOCK TABLES; |
| 132 |
[connection conn1] |
| 133 |
# |
| 134 |
# Step-2.4) Reset the debug signals for the next iteration |
| 135 |
# |
| 136 |
[connection conn2] |
| 137 |
SET debug_sync="RESET"; |
| 138 |
[connection conn1] |
| 139 |
BEGIN; |
| 140 |
INSERT INTO t1 VALUES (1); |
| 141 |
SET debug_sync="bgc_after_flush_stage_before_sync_stage SIGNAL reached WAIT_FOR insert_continue"; |
| 142 |
COMMIT; |
| 143 |
[connection conn2] |
| 144 |
SET debug_sync="now WAIT_FOR reached"; |
| 145 |
FLUSH TABLES WITH READ LOCK; |
| 146 |
[connection conn3] |
| 147 |
SET debug_sync="now SIGNAL insert_continue"; |
| 148 |
[connection conn2] |
| 149 |
RESET MASTER; |
| 150 |
UNLOCK TABLES; |
| 151 |
[connection conn1] |
| 152 |
# |
| 153 |
# Step-2.4) Reset the debug signals for the next iteration |
| 154 |
# |
| 155 |
[connection conn2] |
| 156 |
SET debug_sync="RESET"; |
| 157 |
[connection conn1] |
| 158 |
BEGIN; |
| 159 |
INSERT INTO t1 VALUES (1); |
| 160 |
SET debug_sync="bgc_after_sync_stage_before_commit_stage SIGNAL reached WAIT_FOR insert_continue"; |
| 161 |
COMMIT; |
| 162 |
[connection conn2] |
| 163 |
SET debug_sync="now WAIT_FOR reached"; |
| 164 |
FLUSH TABLES WITH READ LOCK; |
| 165 |
[connection conn3] |
| 166 |
SET debug_sync="now SIGNAL insert_continue"; |
| 167 |
[connection conn2] |
| 168 |
RESET MASTER; |
| 169 |
UNLOCK TABLES; |
| 170 |
[connection conn1] |
| 171 |
# |
| 172 |
# Step-2.4) Reset the debug signals for the next iteration |
| 173 |
# |
| 174 |
[connection conn2] |
| 175 |
SET debug_sync="RESET"; |
| 176 |
[connection conn1] |
| 177 |
BEGIN; |
| 178 |
INSERT INTO t1 VALUES (1); |
| 179 |
SET debug_sync="bgc_after_commit_stage_before_rotation SIGNAL reached WAIT_FOR insert_continue"; |
| 180 |
COMMIT; |
| 181 |
[connection conn2] |
| 182 |
SET debug_sync="now WAIT_FOR reached"; |
| 183 |
FLUSH TABLES WITH READ LOCK; |
| 184 |
[connection conn3] |
| 185 |
SET debug_sync="now SIGNAL insert_continue"; |
| 186 |
[connection conn2] |
| 187 |
RESET MASTER; |
| 188 |
UNLOCK TABLES; |
| 189 |
[connection conn1] |
| 190 |
# |
| 191 |
# Step-2.4) Reset the debug signals for the next iteration |
| 192 |
# |
| 193 |
[connection conn2] |
| 194 |
SET debug_sync="RESET"; |
| 195 |
[connection conn1] |
| 196 |
BEGIN; |
| 197 |
INSERT INTO t1 VALUES (1); |
| 198 |
SET debug_sync="ha_commit_trans_before_acquire_commit_lock SIGNAL reached WAIT_FOR insert_continue"; |
| 199 |
COMMIT; |
| 200 |
[connection conn2] |
| 201 |
SET debug_sync="now WAIT_FOR reached"; |
| 202 |
FLUSH TABLES WITH READ LOCK; |
| 203 |
SET debug_sync="now SIGNAL insert_continue"; |
| 204 |
[connection conn4] |
| 205 |
RESET MASTER; |
| 206 |
[connection conn2] |
| 207 |
UNLOCK TABLES; |
| 208 |
[connection conn1] |
| 209 |
# |
| 210 |
# Step-2.4) Reset the debug signals for the next iteration |
| 211 |
# |
| 212 |
[connection conn2] |
| 213 |
SET debug_sync="RESET"; |
| 214 |
[connection conn1] |
| 215 |
BEGIN; |
| 216 |
INSERT INTO t1 VALUES (1); |
| 217 |
SET debug_sync="bgc_before_flush_stage SIGNAL reached WAIT_FOR insert_continue"; |
| 218 |
COMMIT; |
| 219 |
[connection conn2] |
| 220 |
SET debug_sync="now WAIT_FOR reached"; |
| 221 |
FLUSH TABLES WITH READ LOCK; |
| 222 |
[connection conn3] |
| 223 |
SET debug_sync="now SIGNAL insert_continue"; |
| 224 |
[connection conn2] |
| 225 |
[connection conn4] |
| 226 |
RESET MASTER; |
| 227 |
[connection conn2] |
| 228 |
UNLOCK TABLES; |
| 229 |
[connection conn1] |
| 230 |
# |
| 231 |
# Step-2.4) Reset the debug signals for the next iteration |
| 232 |
# |
| 233 |
[connection conn2] |
| 234 |
SET debug_sync="RESET"; |
| 235 |
[connection conn1] |
| 236 |
BEGIN; |
| 237 |
INSERT INTO t1 VALUES (1); |
| 238 |
SET debug_sync="bgc_after_flush_stage_before_sync_stage SIGNAL reached WAIT_FOR insert_continue"; |
| 239 |
COMMIT; |
| 240 |
[connection conn2] |
| 241 |
SET debug_sync="now WAIT_FOR reached"; |
| 242 |
FLUSH TABLES WITH READ LOCK; |
| 243 |
[connection conn3] |
| 244 |
SET debug_sync="now SIGNAL insert_continue"; |
| 245 |
[connection conn2] |
| 246 |
[connection conn4] |
| 247 |
RESET MASTER; |
| 248 |
[connection conn2] |
| 249 |
UNLOCK TABLES; |
| 250 |
[connection conn1] |
| 251 |
# |
| 252 |
# Step-2.4) Reset the debug signals for the next iteration |
| 253 |
# |
| 254 |
[connection conn2] |
| 255 |
SET debug_sync="RESET"; |
| 256 |
[connection conn1] |
| 257 |
BEGIN; |
| 258 |
INSERT INTO t1 VALUES (1); |
| 259 |
SET debug_sync="bgc_after_sync_stage_before_commit_stage SIGNAL reached WAIT_FOR insert_continue"; |
| 260 |
COMMIT; |
| 261 |
[connection conn2] |
| 262 |
SET debug_sync="now WAIT_FOR reached"; |
| 263 |
FLUSH TABLES WITH READ LOCK; |
| 264 |
[connection conn3] |
| 265 |
SET debug_sync="now SIGNAL insert_continue"; |
| 266 |
[connection conn2] |
| 267 |
[connection conn4] |
| 268 |
RESET MASTER; |
| 269 |
[connection conn2] |
| 270 |
UNLOCK TABLES; |
| 271 |
[connection conn1] |
| 272 |
# |
| 273 |
# Step-2.4) Reset the debug signals for the next iteration |
| 274 |
# |
| 275 |
[connection conn2] |
| 276 |
SET debug_sync="RESET"; |
| 277 |
[connection conn1] |
| 278 |
BEGIN; |
| 279 |
INSERT INTO t1 VALUES (1); |
| 280 |
SET debug_sync="bgc_after_commit_stage_before_rotation SIGNAL reached WAIT_FOR insert_continue"; |
| 281 |
COMMIT; |
| 282 |
[connection conn2] |
| 283 |
SET debug_sync="now WAIT_FOR reached"; |
| 284 |
FLUSH TABLES WITH READ LOCK; |
| 285 |
[connection conn3] |
| 286 |
SET debug_sync="now SIGNAL insert_continue"; |
| 287 |
[connection conn2] |
| 288 |
[connection conn4] |
| 289 |
RESET MASTER; |
| 290 |
[connection conn2] |
| 291 |
UNLOCK TABLES; |
| 292 |
[connection conn1] |
| 293 |
# |
| 294 |
# Step-2.4) Reset the debug signals for the next iteration |
| 295 |
# |
| 296 |
[connection conn2] |
| 297 |
SET debug_sync="RESET"; |
| 298 |
# |
| 299 |
# Step-3) Check that 'RESET MASTER' fails if it is executed from a |
| 300 |
# session that has already acquired locks on a table. |
| 301 |
# |
| 302 |
LOCK TABLE t1 READ; |
| 303 |
RESET MASTER; |
| 304 |
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction |
| 305 |
UNLOCK TABLES; |
| 306 |
LOCK TABLE t1 WRITE; |
| 307 |
RESET MASTER; |
| 308 |
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction |
| 309 |
UNLOCK TABLES; |
| 310 |
# Step-4) Cleanup |
| 311 |
# |
| 312 |
DROP TABLE t1; |