| 1 |
# |
| 2 |
# Test behaviour of DDL query killed while waiting to acquire |
| 3 |
# global schema lock(GSL). |
| 4 |
# |
| 5 |
# NOTE! The query will not be killed immediately, but rather |
| 6 |
# somewhat later when NDB returns control back to the MySQL Server |
| 7 |
# and it can detect that the query has been killed. |
| 8 |
# |
| 9 |
--source include/have_ndb.inc |
| 10 |
# Test uses DEBUG_SYNC |
| 11 |
--source include/have_debug_sync.inc |
| 12 |
|
| 13 |
CREATE TABLE t1 ( |
| 14 |
id INT PRIMARY KEY, |
| 15 |
value INT, |
| 16 |
value2 VARCHAR(50), |
| 17 |
INDEX(value, value2) |
| 18 |
) ENGINE=NDB; |
| 19 |
|
| 20 |
INSERT INTO t1 VALUES(1, 1, "val1"); |
| 21 |
|
| 22 |
# Create two more connection to first mysqld |
| 23 |
--connect (con2,127.0.0.1,root,,test,$MASTER_MYPORT,) |
| 24 |
--connect (con_kill,127.0.0.1,root,,test,$MASTER_MYPORT,) |
| 25 |
|
| 26 |
--echo # Switch to second connection |
| 27 |
--connection con2 |
| 28 |
|
| 29 |
--echo # Reset all DEBUG_SYNC points |
| 30 |
SET DEBUG_SYNC='RESET'; |
| 31 |
--echo # Setup ALTER TABLE to wait after GSL acquired |
| 32 |
SET DEBUG_SYNC='ndb_global_schema_lock_acquired |
| 33 |
SIGNAL got_GSL WAIT_FOR alter_continue'; |
| 34 |
|
| 35 |
--echo # Start ALTER TABLE query, should take GSL, reach the synch |
| 36 |
--echo # point, signal and wait |
| 37 |
--send ALTER TABLE t1 ADD COLUMN value3 BLOB DEFAULT NULL |
| 38 |
|
| 39 |
--echo # Switch to default connection |
| 40 |
--connection default |
| 41 |
|
| 42 |
--echo # Wait for the ALTER TABLE query to signal that it has acquired the GSL |
| 43 |
SET DEBUG_SYNC='now WAIT_FOR got_GSL'; |
| 44 |
|
| 45 |
# Switch to third connection |
| 46 |
--connection con_kill |
| 47 |
|
| 48 |
# Save this connections id for the kill |
| 49 |
let $alter_con_id = `SELECT CONNECTION_ID()`; |
| 50 |
#echo alter_con_id: $alter_con_id; |
| 51 |
|
| 52 |
--echo # Start second ALTER TABLE query which will hang waiting on GSL |
| 53 |
--send ALTER TABLE t1 ADD COLUMN value4 BLOB DEFAULT NULL |
| 54 |
|
| 55 |
--echo # Switch to default connection |
| 56 |
--connection default |
| 57 |
|
| 58 |
# Wait until the ALTER is hanging on GSL |
| 59 |
let $wait_condition= |
| 60 |
SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST |
| 61 |
WHERE STATE LIKE "Waiting for ndbcluster global schema lock"; |
| 62 |
--source include/wait_condition.inc |
| 63 |
|
| 64 |
--echo # Kill the hanging ALTER |
| 65 |
--replace_result $alter_con_id <CONNECTION_ID> |
| 66 |
eval KILL QUERY $alter_con_id; |
| 67 |
|
| 68 |
--echo # Switch to third connection |
| 69 |
--connection con_kill |
| 70 |
|
| 71 |
--echo # Complete the killed ALTER TABLE query, it's expected to fail since |
| 72 |
--echo # it was killed |
| 73 |
--error ER_LOCK_REFUSED_BY_ENGINE |
| 74 |
--reap |
| 75 |
SHOW WARNINGS; |
| 76 |
|
| 77 |
--echo # Tell the ALTER TABLE which holds GSL to continue processing |
| 78 |
SET DEBUG_SYNC='now SIGNAL alter_continue'; |
| 79 |
|
| 80 |
--echo # Switch to second connection |
| 81 |
--connection con2 |
| 82 |
|
| 83 |
--echo # Complete the ALTER TABLE query |
| 84 |
--reap |
| 85 |
|
| 86 |
--echo # Switch to default connection |
| 87 |
--connection default |
| 88 |
|
| 89 |
# Reset all DEBUG_SYNC points |
| 90 |
SET DEBUG_SYNC='RESET'; |
| 91 |
|
| 92 |
DROP TABLE t1; |