#
# MDEV-36959 Deadlock does not rollback transaction fully
#
CREATE TABLE t1(col1 INT PRIMARY KEY, col2 INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, 1), (2, 2);
SELECT * FROM t1;
col1 col2 11 22
connect con1,localhost,root,,;
START TRANSACTION;
# Trx-1: Lock 1st record
UPDATE t1 SET col2=10 where col1=1;
connection default;
START TRANSACTION;
# Trx-2: Lock 2nd record
UPDATE t1 SET col2=100 where col1=2;
connection con1;
# Trx-1: Try locking 1st record : Wait
UPDATE t1 SET col2=10 where col1=2;
connection default;
# Wait for Trx-1 to get into lock wait stage
# Trx-2: Try locking 2nd record : Deadlock
UPDATE t1 SET col2=100 where col1=1; ERROR40001: Deadlock found when trying to get lock; try restarting transaction
connection con1;
ROLLBACK;
connection default;
SELECT @@in_transaction;
@@in_transaction 0
UPDATE t1 SET col2=10 where col1=1;
UPDATE t1 SET col2=100 where col1=2;
SELECT @@in_transaction;
@@in_transaction 0
ROLLBACK;
SELECT * FROM t1;
col1 col2 110 2100
DROP TABLE t1;
#
# MDEV-37141 DML committed within XA transaction block after deadlock errorand implicit rollback
#
CREATE TABLE t1(col1 INT PRIMARY KEY, col2 INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, 1), (2, 2);
SELECT * FROM t1;
col1 col2 11 22
# Wait for information schema cache for locks to get cleared
connection con1;
XA BEGIN 'x1';
# XA Trx-1: Lock 1st record
UPDATE t1 SET col2=10 where col1=1;
connection default;
XA BEGIN 'x2';
# XA Trx-2: Lock 2nd record
UPDATE t1 SET col2=100 where col1=2;
connection con1;
# XA Trx-1: Try locking 1st record : Wait
UPDATE t1 SET col2=10 where col1=2;
connection default;
# Wait for XA Trx-1 to get into lock wait stage
# XA Trx-2: Try locking 2nd record : Deadlock
UPDATE t1 SET col2=100 where col1=1; ERROR40001: Deadlock found when trying to get lock; try restarting transaction
INSERT INTO t1 VALUES (3, 3), (4, 4); ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the ROLLBACK ONLY state
XA END 'x2'; ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the ROLLBACK ONLY state
XA ROLLBACK 'x2';
connection con1;
XA END 'x1';
XA ROLLBACK 'x1';
connection default;
SELECT * FROM t1;
col1 col2 11 22
DROP TABLE t1;
disconnect con1;
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-10-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.