Skip to content

Commit cd10959

Browse files
author
Alexey Botchkov
committed
MDEV-15217 Assertion `thd->transaction.xid_state.xid.is_null()' failed
in trans_xa_start. THD.transaction.xid_state.xid.rm_error should be cleaned as the thread ends.
1 parent 2877704 commit cd10959

File tree

3 files changed

+59
-1
lines changed

3 files changed

+59
-1
lines changed

mysql-test/r/xa.result

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,25 @@ XA ROLLBACK 'xid1';
270270
connection default;
271271
DROP TABLE t1, t2;
272272
disconnect con2;
273+
CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=InnoDB;
274+
CREATE TABLE t2 (pk INT PRIMARY KEY) ENGINE=InnoDB;
275+
INSERT INTO t2 VALUES (1),(2);
276+
CREATE TABLE t3 (i INT) ENGINE=InnoDB;
277+
XA BEGIN 'xid1';
278+
REPLACE INTO t1 SELECT * FROM t2;
279+
connect con1,localhost,root,,test;
280+
XA BEGIN 'xid2';
281+
INSERT INTO t1 SELECT * FROM t2;
282+
connection default;
283+
REPLACE INTO t2 SELECT * FROM t2;
284+
connection con1;
285+
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
286+
disconnect con1;
287+
connect con2,localhost,root,,test;
288+
INSERT INTO t3 VALUES (1);
289+
XA BEGIN 'xid3';
290+
disconnect con2;
291+
connection default;
292+
XA END 'xid1';
293+
XA ROLLBACK 'xid1';
294+
DROP TABLE t1, t2, t3;

mysql-test/t/xa.test

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,41 @@ DROP TABLE t1, t2;
394394
disconnect con2;
395395

396396

397-
# Wait till all disconnects are completed
397+
#
398+
# MDEV 15217 Assertion `thd->transaction.xid_state.xid.is_null()' failed in trans_xa_start.
399+
#
400+
CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=InnoDB;
401+
CREATE TABLE t2 (pk INT PRIMARY KEY) ENGINE=InnoDB;
402+
INSERT INTO t2 VALUES (1),(2);
403+
CREATE TABLE t3 (i INT) ENGINE=InnoDB;
404+
405+
XA BEGIN 'xid1';
406+
REPLACE INTO t1 SELECT * FROM t2;
407+
408+
--connect (con1,localhost,root,,test)
409+
XA BEGIN 'xid2';
410+
--send
411+
INSERT INTO t1 SELECT * FROM t2;
412+
413+
--connection default
414+
REPLACE INTO t2 SELECT * FROM t2;
415+
416+
--connection con1
417+
--error ER_LOCK_DEADLOCK
418+
--reap
419+
--disconnect con1
420+
421+
--connect (con2,localhost,root,,test)
422+
INSERT INTO t3 VALUES (1);
423+
XA BEGIN 'xid3';
424+
425+
426+
#Cleanup
427+
--disconnect con2
428+
--connection default
429+
XA END 'xid1';
430+
XA ROLLBACK 'xid1';
431+
DROP TABLE t1, t2, t3;
432+
398433
--source include/wait_until_count_sessions.inc
399434

sql/sql_class.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,7 @@ void THD::cleanup(void)
14621462
close_temporary_tables();
14631463

14641464
transaction.xid_state.xa_state= XA_NOTR;
1465+
transaction.xid_state.rm_error= 0;
14651466
trans_rollback(this);
14661467
xid_cache_delete(this, &transaction.xid_state);
14671468

0 commit comments

Comments
 (0)