Commit 75249699 authored by Dmitry Shulga's avatar Dmitry Shulga

Patch for bug#13070308 - VALGRIND failure in XA test.

The issue is that xa.test failed sporadically on some platforms.
The reason for the test failure is a race condition in xa.test.
The race condition occures between connection that executes statement
INSERT INTO t2 SELECT FROM t1 and other connection that tries to run
statements DELETE FROM t1 and COMMIT. If COMMIT statement had been executed
before the statement INSERT INTO t2 SELECT FROM t1 was locked by lock
on table t1 (as a result of query from table t1) then the INSERT statement
is executed successfully and a following test for deadlock would failed.

This patch fixes this race condition by moving COMMIT statement after commit
of distributed transaction from concurrent session.
parent 37fce0ec
......@@ -206,8 +206,8 @@ DROP TABLE t1;
# FAILED
#
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (a INT);
CREATE TABLE t2 (a INT);
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
CREATE TABLE t2 (a INT) ENGINE=InnoDB;
START TRANSACTION;
INSERT INTO t1 VALUES (1);
# Connection con2
......@@ -217,12 +217,14 @@ INSERT INTO t2 SELECT a FROM t1;
# Connection default
# Waiting until INSERT ... is blocked
DELETE FROM t1;
COMMIT;
# Connection con2
# Reaping: INSERT INTO t2 SELECT a FROM t1
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
XA COMMIT 'xid1';
ERROR XA102: XA_RBDEADLOCK: Transaction branch was rolled back: deadlock was detected
# Connection default
COMMIT;
# Connection con2
XA START 'xid1';
XA END 'xid1';
XA PREPARE 'xid1';
......
......@@ -338,8 +338,8 @@ DROP TABLE t1;
DROP TABLE IF EXISTS t1, t2;
--enable_warnings
CREATE TABLE t1 (a INT);
CREATE TABLE t2 (a INT);
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
CREATE TABLE t2 (a INT) ENGINE=InnoDB;
START TRANSACTION;
INSERT INTO t1 VALUES (1);
......@@ -359,7 +359,6 @@ let $wait_condition=
--echo # Waiting until INSERT ... is blocked
--source include/wait_condition.inc
DELETE FROM t1;
COMMIT;
--echo # Connection con2
--connection con2
......@@ -368,6 +367,14 @@ COMMIT;
--reap
--error ER_XA_RBDEADLOCK
XA COMMIT 'xid1';
--echo # Connection default
connection default;
COMMIT;
--echo # Connection con2
connection con2;
# This caused the assert to be triggered
XA START 'xid1';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment