From docs :
If an error occurs with duplicate keys, a general blocking of the duplicate index record is set. This use of shared locks may result in several sessions trying to insert the same row if another session already has an exclusive lock. This can happen if another session deletes the row.
Following the example in the docs,
Assume that the InnoDB t1 table has the following structure:
CREATE TABLE t1 (i INT, PRIMARY KEY (i)) ENGINE = InnoDB;
Now suppose that three sessions perform the following operations:
Session 1:
START TRANSACTION;
INSERT INTO t1 VALUES(1);
Session 2:
START TRANSACTION;
INSERT INTO t1 VALUES(1);
Session 3:
START TRANSACTION;
INSERT INTO t1 VALUES(1);
Session 1:
ROLLBACK;
1 . 2 3 , . 1 , 2 3. , 2 3 : - , .
:
1) , . , , T1 1, 1. , T2 , INNODB , PK ( = 1) T2 ? T2 , PK.
2) T2 T3 ? ?