| 1 |
# |
| 2 |
# MDEV-33064: ALTER INPLACE running TOI should abort a conflicting DML operation |
| 3 |
# |
| 4 |
# DDL operations may commit InnoDB transactions more than once during the execution. |
| 5 |
# In this case wsrep flag on trx object is cleared, which may cause wrong logic of |
| 6 |
# such operations afterwards (wsrep-related hooks are not run). |
| 7 |
# One of the consequences was that DDL operation couldn't abort a DML operation |
| 8 |
# holding conflicting locks. |
| 9 |
# |
| 10 |
# The fix: re-enable wsrep flag on trx restart if it's a part of a DDL operation. |
| 11 |
# |
| 12 |
|
| 13 |
--source include/galera_cluster.inc |
| 14 |
--source include/have_debug_sync.inc |
| 15 |
--source include/have_debug.inc |
| 16 |
|
| 17 |
--connect con1,127.0.0.1,root,,test,$NODE_MYPORT_1 |
| 18 |
|
| 19 |
CREATE TABLE t1(c1 INT PRIMARY KEY) ENGINE=InnoDB; |
| 20 |
CREATE TABLE t1_fk(c1 INT PRIMARY KEY, c2 INT, INDEX (c2), FOREIGN KEY (c2) REFERENCES t1(c1)) ENGINE=InnoDB; |
| 21 |
|
| 22 |
INSERT INTO t1 VALUES (1); |
| 23 |
|
| 24 |
--connection con1 |
| 25 |
SET SESSION wsrep_retry_autocommit = 0; |
| 26 |
SET DEBUG_SYNC = 'ib_after_row_insert SIGNAL may_alter WAIT_FOR bf_abort'; |
| 27 |
# INSERT also grabs FK-referenced table lock. |
| 28 |
--send |
| 29 |
INSERT INTO t1_fk VALUES (1, 1); |
| 30 |
|
| 31 |
--connection node_1 |
| 32 |
SET DEBUG_SYNC = 'now WAIT_FOR may_alter'; |
| 33 |
SET DEBUG_SYNC = 'lock_wait_end WAIT_FOR alter_continue'; |
| 34 |
# ALTER BF-aborts INSERT. |
| 35 |
--send |
| 36 |
ALTER TABLE t1 ADD COLUMN c2 INT, ALGORITHM=INPLACE; |
| 37 |
|
| 38 |
--connection con1 |
| 39 |
# INSERT gets BF-aborted. |
| 40 |
--error ER_LOCK_DEADLOCK |
| 41 |
--reap |
| 42 |
SET DEBUG_SYNC = 'now SIGNAL alter_continue'; |
| 43 |
|
| 44 |
--connection node_1 |
| 45 |
# ALTER succeeds. |
| 46 |
--reap |
| 47 |
|
| 48 |
--connection node_2 |
| 49 |
# Sanity check that ALTER has been replicated. |
| 50 |
INSERT INTO t1 (c1, c2) VALUES (2, 2); |
| 51 |
|
| 52 |
# Cleanup. |
| 53 |
--connection node_1 |
| 54 |
SET DEBUG_SYNC = 'RESET'; |
| 55 |
DROP TABLE t1_fk, t1; |
| 56 |
--disconnect con1 |
| 57 |
--source include/galera_end.inc |