blob: d9919c0348bb8e60a199667a08e61b6c9adb4ac6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
CREATE TABLE parent (
id INT PRIMARY KEY,
KEY (id)
) ENGINE=InnoDB;
CREATE TABLE child (
id INT PRIMARY KEY,
parent_id INT,
FOREIGN KEY (parent_id)
REFERENCES parent(id)
) ENGINE=InnoDB;
INSERT INTO parent VALUES (1), (2);
INSERT INTO child VALUES (1,1);
connection node_1;
SET AUTOCOMMIT = OFF;
START TRANSACTION;
DELETE FROM parent WHERE id = 2;
connection node_2;
SET AUTOCOMMIT = OFF;
START TRANSACTION;
INSERT INTO child VALUES (2, 2);
connection node_1;
COMMIT;
connection node_2;
COMMIT;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
DROP TABLE child;
DROP TABLE parent;
|