mariadb/mysql-test/suite/galera/r/MDEV-32738.result
Denis Protivensky b7718a1c1c MDEV-32738: Don't roll back high-prio txn waiting on a lock in InnoDB
DML transactions on FK-child tables also get table locks
on FK-parent tables. If there is a DML transaction holding
such a lock, and a TOI transaction starts, the latter
BF-aborts the former and puts itself into a waiting state.
If at this moment another DML transaction on FK-child table
starts, it doesn't check that the transaction waiting on
a parent table lock is TOI, and it erroneously BF-aborts
the waiting TOI transaction.

The fix: don't roll back high-priority transaction waiting
on a lock in InnoDB, instead roll back an incoming DML
transaction.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
2024-07-08 23:36:21 +02:00

32 lines
1.2 KiB
Text

connection node_2;
connection node_1;
connect con1_1,127.0.0.1,root,,test,$NODE_MYPORT_1;
connect con1_2,127.0.0.1,root,,test,$NODE_MYPORT_1;
CREATE TABLE t1(c1 INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t1_fk(c1 INT PRIMARY KEY, c2 INT, INDEX (c2), FOREIGN KEY (c2) REFERENCES t1(c1)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
connection con1_1;
SET DEBUG_SYNC = 'ib_after_row_insert WAIT_FOR bf_abort';
INSERT INTO t1_fk VALUES (1, 1);
connection con1_2;
SET DEBUG_SYNC = 'ha_write_row_start SIGNAL may_alter WAIT_FOR may_insert';
INSERT INTO t1_fk VALUES (2, 2);
connection node_1;
SET DEBUG_SYNC = 'now WAIT_FOR may_alter';
SET DEBUG_SYNC = 'after_lock_table_for_trx SIGNAL may_insert WAIT_FOR alter_continue';
ALTER TABLE t1 ADD COLUMN c2 INT;
connection con1_1;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
connection con1_2;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
SET DEBUG_SYNC = 'now SIGNAL alter_continue';
connection node_1;
connection node_2;
INSERT INTO t1 (c1, c2) VALUES (2, 2);
connection node_1;
SET DEBUG_SYNC = 'RESET';
DROP TABLE t1_fk, t1;
disconnect con1_1;
disconnect con1_2;
disconnect node_2;
disconnect node_1;