1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333
|
--echo #
--echo # Bug#22710164 xa with innodb allows a table to be dropped while an xa
--echo # transaction has dml
--echo #
--echo # Enable Lock Instrumentation
--enable_connect_log
let $perf_lock_enabled=`select enabled FROM performance_schema.setup_instruments WHERE name='wait/lock/metadata/sql/mdl'`;
UPDATE performance_schema.setup_instruments SET ENABLED=1 WHERE name='wait/lock/metadata/sql/mdl';
--echo
--echo # Test 1: XA Commit after disconnect
connect (con1, localhost, root, ,test);
CREATE TABLE t1 (a INT);
--echo # Query the table t1 in order to load its definition into the data dictionary cache.
--echo # It is required in order to get consistent result for quering from performance_schema.metadata_locks
--echo # when the test case is run both with and without the option --ps-protocol
--sorted_result
SELECT * FROM t1;
XA START 'test';
INSERT INTO t1 VALUES (10);
XA END 'test';
XA PREPARE 'test';
--echo
--echo # Close connection and check lock status form different connection.
disconnect con1;
--source include/wait_until_disconnected.inc
connection default;
--sorted_result
SELECT * FROM t1;
--sorted_result
SELECT object_type, object_schema, object_name, lock_type, lock_duration, lock_status FROM performance_schema.metadata_locks WHERE object_schema = 'test';
SHOW TABLES;
--sorted_result
XA RECOVER;
--echo
--echo # Commit XA and check lock status.
XA COMMIT 'test';
--sorted_result
SELECT object_type, object_schema, object_name, lock_type, lock_duration, lock_status FROM performance_schema.metadata_locks WHERE object_schema = 'test';
--sorted_result
XA RECOVER;
--sorted_result
SELECT * FROM t1;
DROP TABLE t1;
--echo
--echo # Test 2: XA Rollback after disconnect
connect (con1, localhost, root, ,test);
CREATE TABLE t1 (a INT);
--echo # Query the table t1 in order to load its definition into the data dictionary cache.
--echo # It is required in order to get consistent result for quering from performance_schema.metadata_locks
--echo # when the test case is run both with and without the option --ps-protocol
--sorted_result
SELECT * FROM t1;
XA START 'test';
INSERT INTO t1 VALUES (10);
XA END 'test';
XA PREPARE 'test';
--echo
--echo # Close connection and check lock status form different connection.
disconnect con1;
--source include/wait_until_disconnected.inc
connection default;
--sorted_result
SELECT * FROM t1;
--sorted_result
SELECT object_type, object_schema, object_name, lock_type, lock_duration, lock_status FROM performance_schema.metadata_locks WHERE object_schema = 'test';
SHOW TABLES;
--sorted_result
XA RECOVER;
--echo
--echo # Rollback XA and check lock status.
XA ROLLBACK 'test';
--sorted_result
SELECT object_type, object_schema, object_name, lock_type, lock_duration, lock_status FROM performance_schema.metadata_locks WHERE object_schema = 'test';
--sorted_result
XA RECOVER;
--sorted_result
SELECT * FROM t1;
DROP TABLE t1;
--echo
--echo # Test 3: Waiting LOCK requests are not granted during lock transfer to backup
connect (con1, localhost, root, ,test);
CREATE TABLE t1 (a INT);
--echo # Query the table t1 in order to load its definition into the data dictionary cache.
--echo # It is required in order to get consistent result for quering from performance_schema.metadata_locks
--echo # when the test case is run both with and without the option --ps-protocol
--sorted_result
SELECT * FROM t1;
XA START 'test';
INSERT INTO t1 VALUES (10);
XA END 'test';
XA PREPARE 'test';
connect (con2, localhost, root, ,test);
--sorted_result
SELECT * FROM t1;
--send DROP TABLE t1
connection default;
let $wait_condition=SELECT count(*) = 2 from performance_schema.metadata_locks where object_name='t1';
--source include/wait_condition.inc
--echo
--echo # Close connection and check lock status form different connection.
connection con1;
disconnect con1;
--source include/wait_until_disconnected.inc
connection default;
--sorted_result
SELECT object_type, object_schema, object_name, lock_type, lock_duration, lock_status FROM performance_schema.metadata_locks WHERE object_schema = 'test';
SHOW TABLES;
--sorted_result
XA RECOVER;
--echo
--echo # Commit XA and check lock status.
XA COMMIT 'test';
let $wait_condition=SELECT count(*) = 0 from performance_schema.metadata_locks where object_name='t1';
--source include/wait_condition.inc
--sorted_result
SELECT object_type, object_schema, object_name, lock_type, lock_duration, lock_status FROM performance_schema.metadata_locks WHERE object_schema = 'test';
--sorted_result
XA RECOVER;
connection con2;
--reap
disconnect con2;
--source include/wait_until_disconnected.inc
connection default;
--echo
--echo # Test 4: XA Commit after restart
connect (con1, localhost, root, ,test);
CREATE TABLE t1 (a INT);
XA START 'test';
INSERT INTO t1 VALUES (10);
XA END 'test';
XA PREPARE 'test';
--echo
--echo # Restart server and check lock status.
disconnect con1;
--source include/wait_until_disconnected.inc
connection default;
--let $restart_parameters=restart:--log_error_verbosity=1 --performance-schema-instrument='wait/lock/metadata/sql/mdl=1'
--source include/restart_mysqld.inc
--sorted_result
SELECT * FROM t1;
--sorted_result
SELECT object_type, object_schema, object_name, lock_type, lock_duration, lock_status FROM performance_schema.metadata_locks WHERE object_schema = 'test';
SHOW TABLES;
--sorted_result
XA RECOVER;
--echo
--echo # Commit XA and check lock status.
XA COMMIT 'test';
--sorted_result
SELECT object_type, object_schema, object_name, lock_type, lock_duration, lock_status FROM performance_schema.metadata_locks WHERE object_schema = 'test';
--sorted_result
XA RECOVER;
--sorted_result
SELECT * FROM t1;
DROP TABLE t1;
--echo
--echo # Test 5: XA Rollback after restart
connect (con1, localhost, root, ,test);
CREATE TABLE t1 (a INT);
XA START 'test';
INSERT INTO t1 VALUES (10);
XA END 'test';
XA PREPARE 'test';
--echo
--echo # Restart server and check lock status.
disconnect con1;
--source include/wait_until_disconnected.inc
connection default;
--let $restart_parameters=restart:--log_error_verbosity=1 --performance-schema-instrument='wait/lock/metadata/sql/mdl=1'
--source include/restart_mysqld.inc
--sorted_result
SELECT * FROM t1;
--sorted_result
SELECT object_type, object_schema, object_name, lock_type, lock_duration, lock_status FROM performance_schema.metadata_locks WHERE object_schema = 'test';
SHOW TABLES;
--sorted_result
XA RECOVER;
--echo
--echo # Rollback XA and check lock status.
XA ROLLBACK 'test';
--sorted_result
SELECT object_type, object_schema, object_name, lock_type, lock_duration, lock_status FROM performance_schema.metadata_locks WHERE object_schema = 'test';
--sorted_result
XA RECOVER;
--sorted_result
SELECT * FROM t1;
DROP TABLE t1;
--echo
--echo # Test 6: Multiple XA Transaction in Backup
--echo # Insert 3 XA into backup, delete in different order, check lock status
--enable_connect_log
CREATE TABLE t1 (a INT);
CREATE TABLE t2 (a INT);
CREATE TABLE t3 (a INT);
--echo # Query the tables t1, t2, t3 in order to load their definitions into the data dictionary cache.
--echo # It is required in order to get consistent result for quering from performance_schema.metadata_locks
--echo # when the test case is run both with and without the option --ps-protocol
--sorted_result
SELECT * FROM t1;
--sorted_result
SELECT * FROM t2;
--sorted_result
SELECT * FROM t3;
connect (con1, localhost, root, ,test);
XA START 'test1';
INSERT INTO t1 VALUES (10);
XA END 'test1';
XA PREPARE 'test1';
disconnect con1;
--source include/wait_until_disconnected.inc
connect (con1, localhost, root, ,test);
XA START 'test2';
INSERT INTO t2 VALUES (20);
XA END 'test2';
XA PREPARE 'test2';
disconnect con1;
--source include/wait_until_disconnected.inc
connect (con1, localhost, root, ,test);
XA START 'test3';
INSERT INTO t3 VALUES (30);
XA END 'test3';
XA PREPARE 'test3';
disconnect con1;
--source include/wait_until_disconnected.inc
connection default;
--sorted_result
SELECT object_type, object_schema, object_name, lock_type, lock_duration, lock_status FROM performance_schema.metadata_locks WHERE object_schema = 'test';
SHOW TABLES;
--sorted_result
XA RECOVER;
--echo
--echo # Commit second XA and check lock status.
XA COMMIT 'test2';
--sorted_result
SELECT object_type, object_schema, object_name, lock_type, lock_duration, lock_status FROM performance_schema.metadata_locks WHERE object_schema = 'test';
--sorted_result
XA RECOVER;
DROP TABLE t2;
--echo # Commit First XA
XA COMMIT 'test1';
--sorted_result
SELECT object_type, object_schema, object_name, lock_type, lock_duration, lock_status FROM performance_schema.metadata_locks WHERE object_schema = 'test';
--sorted_result
XA RECOVER;
DROP TABLE t1;
--echo # Commit Last XA
XA COMMIT 'test3';
--sorted_result
SELECT object_type, object_schema, object_name, lock_type, lock_duration, lock_status FROM performance_schema.metadata_locks WHERE object_schema = 'test';
--sorted_result
XA RECOVER;
DROP TABLE t3;
--echo
--echo # Test 7: Multiple XA in recovery
--enable_connect_log
CREATE TABLE t1 (a INT);
CREATE TABLE t2 (a INT);
connect (con1, localhost, root, ,test);
XA START 'test1';
INSERT INTO t1 VALUES (10);
XA END 'test1';
XA PREPARE 'test1';
disconnect con1;
--source include/wait_until_disconnected.inc
connect (con1, localhost, root, ,test);
XA START 'test2';
INSERT INTO t2 VALUES (20);
XA END 'test2';
XA PREPARE 'test2';
disconnect con1;
--source include/wait_until_disconnected.inc
--echo
--echo # Restart server and check lock status.
connection default;
--let $restart_parameters=restart:--log_error_verbosity=1 --performance-schema-instrument='wait/lock/metadata/sql/mdl=1'
--source include/restart_mysqld.inc
--sorted_result
SELECT object_type, object_schema, object_name, lock_type, lock_duration, lock_status FROM performance_schema.metadata_locks WHERE object_schema = 'test';
SHOW TABLES;
--sorted_result
XA RECOVER;
--echo
--echo # Commit First XA
XA COMMIT 'test1';
--sorted_result
SELECT object_type, object_schema, object_name, lock_type, lock_duration, lock_status FROM performance_schema.metadata_locks WHERE object_schema = 'test';
--sorted_result
XA RECOVER;
DROP TABLE t1;
--echo
--echo # Commit second XA
XA COMMIT 'test2';
--sorted_result
SELECT object_type, object_schema, object_name, lock_type, lock_duration, lock_status FROM performance_schema.metadata_locks WHERE object_schema = 'test';
--sorted_result
XA RECOVER;
DROP TABLE t2;
--echo # Cleanup
--eval UPDATE performance_schema.setup_instruments SET ENABLED='$perf_lock_enabled' WHERE name='wait/lock/metadata/sql/mdl'
--disable_connect_log
# Restore default settings
--let $restart_parameters = restart:
--source include/restart_mysqld.inc
|