Invalid deadlock error when inserting concurrently into an AUTO_INCREMENT column

Bug #1372986 reported by Philip Stoev
6
This bug affects 1 person
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/galera_cluster.inc
--source include/have_innodb.inc

# Create a second connection to node1 so that we can run transactions concurrently
--let $galera_connection_name = node_1a
--let $galera_server_number = 1
--source include/galera_connect.inc

--connection node_1
SET GLOBAL wsrep_sync_wait = 7;
CREATE TABLE ten (f1 INTEGER);
INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);

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_SCHEMA.PROCESSLIST WHERE USER = 'system user';

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;

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.