Invalid deadlock error when inserting concurrently into an AUTO_INCREMENT column
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
MySQL patches by Codership | Status tracked in 5.6 | |||||
5.6 |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Concurrent INSERTs with an auto_increment column produce an unexpected "Deadlock found when trying to get lock; try restarting transaction" error.
This does not happen if the column is not auto_increment.
Test case:
--source include/
--source include/
# Create a second connection to node1 so that we can run transactions concurrently
--let $galera_
--let $galera_
--source include/
--connection node_1
SET GLOBAL wsrep_sync_wait = 7;
CREATE TABLE ten (f1 INTEGER);
INSERT INTO ten VALUES (1),(2)
CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 INTEGER) Engine=InnoDB;
--connection node_2
SET GLOBAL wsrep_sync_wait = 7;
--connection node_1
--send INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3;
--connection node_1a
--send INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3;
--connection node_2
--send INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3;
--connection node_1
--reap
--connection node_1a
--reap
--connection node_2
--reap
SELECT COUNT(*) = 30000 FROM t1;
SELECT COUNT(DISTINCT f1) = 30000 FROM t1;
SELECT COUNT(*) = 5 FROM INFORMATION_
SET GLOBAL wsrep_slave_threads = 1;
SET GLOBAL wsrep_sync_wait = 0;
--connection default
SET GLOBAL wsrep_sync_wait = 0;
DROP TABLE t1;
DROP TABLE ten;