Skip to content

Commit 0907df3

Browse files
committed
MDEV-34204 Assertion `!*detailed_error' failed on shutdown after XA PREPARE
trx_free_at_shutdown(): Similar to trx_t::commit_in_memory(), clear the detailed_error (FOREIGN KEY constraint error) before invoking trx_t::free(). We only do this on debug instrumented builds in order to avoid a debug assertion failure on shutdown.
1 parent 698dae5 commit 0907df3

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

mysql-test/suite/innodb/r/xa_recovery.result

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
1+
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
22
INSERT INTO t1 VALUES (1);
33
connect con1,localhost,root;
44
XA START 'x';
55
UPDATE t1 set a=2;
66
XA END 'x';
77
XA PREPARE 'x';
88
connect con2,localhost,root;
9-
CREATE TABLE t2 (a INT) ENGINE=InnoDB;
9+
CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
1010
XA START 'y';
1111
INSERT INTO t2 VALUES (1);
1212
XA END 'y';
@@ -29,7 +29,18 @@ XA ROLLBACK 'x';
2929
SELECT * FROM t1;
3030
a
3131
1
32-
DROP TABLE t1;
32+
CREATE TABLE t3(a INT PRIMARY KEY REFERENCES t1(a)) ENGINE=InnoDB;
33+
XA START 'a';
34+
INSERT INTO t3 SET a=1;
35+
INSERT INTO t3 SET a=42;
36+
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t3`, CONSTRAINT `t3_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
37+
XA END 'a';
38+
XA PREPARE 'a';
3339
SET GLOBAL innodb_fast_shutdown=0;
3440
# restart
41+
XA COMMIT 'a';
42+
SELECT * FROM t3;
43+
a
44+
1
45+
DROP TABLE t3,t1;
3546
XA ROLLBACK 'y';

mysql-test/suite/innodb/t/xa_recovery.test

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ call mtr.add_suppression("Found [12] prepared XA transactions");
1010
FLUSH TABLES;
1111
--enable_query_log
1212

13-
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
13+
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
1414
INSERT INTO t1 VALUES (1);
1515
connect (con1,localhost,root);
1616
XA START 'x'; UPDATE t1 set a=2; XA END 'x'; XA PREPARE 'x';
1717
connect (con2,localhost,root);
18-
CREATE TABLE t2 (a INT) ENGINE=InnoDB;
18+
CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
1919
XA START 'y'; INSERT INTO t2 VALUES (1); XA END 'y'; XA PREPARE 'y';
2020
connection default;
2121

@@ -53,9 +53,18 @@ SELECT * FROM t1;
5353
XA ROLLBACK 'x';
5454
SELECT * FROM t1;
5555

56-
DROP TABLE t1;
56+
CREATE TABLE t3(a INT PRIMARY KEY REFERENCES t1(a)) ENGINE=InnoDB;
57+
XA START 'a';
58+
INSERT INTO t3 SET a=1;
59+
--error ER_NO_REFERENCED_ROW_2
60+
INSERT INTO t3 SET a=42;
61+
XA END 'a';
62+
XA PREPARE 'a';
5763

5864
SET GLOBAL innodb_fast_shutdown=0;
5965
--source include/restart_mysqld.inc
6066

67+
XA COMMIT 'a';
68+
SELECT * FROM t3;
69+
DROP TABLE t3,t1;
6170
XA ROLLBACK 'y';

storage/innobase/trx/trx0trx.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ trx_free_at_shutdown(trx_t *trx)
554554
trx->state = TRX_STATE_NOT_STARTED;
555555
ut_ad(!UT_LIST_GET_LEN(trx->lock.trx_locks));
556556
trx->id = 0;
557+
ut_d(*trx->detailed_error = '\0');
557558
trx->free();
558559
}
559560

0 commit comments

Comments
 (0)