blob: 30009b8ddc9ab91b10fd183d52efea06e4c4bb67 (
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#
#Bug#11759688 52020: InnoDB can still deadlock
#on just INSERT...ON DUPLICATE KEY
#a.k.a. Bug#7975 deadlock without any locking, simple select and update
#
CREATE TABLE t1 (a INT PRIMARY KEY, b INT NOT NULL) ENGINE=InnoDB;
INSERT INTO t1 VALUES(3,1);
BEGIN;
SET DEBUG_SYNC='write_row_noreplace SIGNAL insert1 WAIT_FOR select1';
INSERT INTO t1 VALUES(3,2);
SET DEBUG_SYNC='now WAIT_FOR insert1';
SELECT * FROM t1 LOCK IN SHARE MODE;
a b
3 1
SELECT * FROM t1 FOR UPDATE;
SET DEBUG_SYNC='now SIGNAL select1';
ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
INSERT INTO t1 VALUES(3,3) ON DUPLICATE KEY UPDATE b=b+10;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
COMMIT;
SET DEBUG_SYNC='write_row_replace SIGNAL insert2 WAIT_FOR select2';
REPLACE INTO t1 VALUES(3,4);
SET DEBUG_SYNC='now WAIT_FOR insert2';
SELECT * FROM t1;
a b
3 11
SELECT * FROM t1 LOCK IN SHARE MODE;
SET DEBUG_SYNC='now SIGNAL select2';
SET DEBUG_SYNC='write_row_replace SIGNAL insert3 WAIT_FOR select3';
INSERT INTO t1 VALUES(3,5) ON DUPLICATE KEY UPDATE b=b+20;
a b
3 4
SET DEBUG_SYNC='now WAIT_FOR insert3';
SELECT b FROM t1 LOCK IN SHARE MODE;
SET DEBUG_SYNC='now SIGNAL select3';
b
24
SET DEBUG_SYNC='write_row_noreplace SIGNAL insert4 WAIT_FOR select4';
LOAD DATA INFILE '../../std_data/loaddata5.dat' INTO TABLE t1 FIELDS TERMINATED BY '' ENCLOSED BY '' (a, b);
SET DEBUG_SYNC='now WAIT_FOR insert4';
SELECT b FROM t1 WHERE a=3 LOCK IN SHARE MODE;
b
24
SELECT b FROM t1 WHERE a=3 FOR UPDATE;
SET DEBUG_SYNC='now SIGNAL select4';
b
24
ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
SET DEBUG_SYNC='write_row_noreplace SIGNAL insert5 WAIT_FOR select5';
LOAD DATA INFILE '../../std_data/loaddata5.dat' IGNORE INTO TABLE t1 FIELDS TERMINATED BY '' ENCLOSED BY '' (a, b);
SET DEBUG_SYNC='now WAIT_FOR insert5';
SELECT * FROM t1;
a b
3 24
SELECT * FROM t1 WHERE a=3 LOCK IN SHARE MODE;
a b
3 24
SELECT * FROM t1 WHERE a=3 FOR UPDATE;
SET DEBUG_SYNC='now SIGNAL select5';
a b
3 24
SET DEBUG_SYNC='write_row_replace SIGNAL insert6 WAIT_FOR select6';
LOAD DATA INFILE '../../std_data/loaddata5.dat' REPLACE INTO TABLE t1 FIELDS TERMINATED BY '' ENCLOSED BY '' (a, b);
SET DEBUG_SYNC='now WAIT_FOR insert6';
SELECT * FROM t1;
a b
1 2
3 24
5 6
SELECT a,b FROM t1 LOCK IN SHARE MODE;
SET DEBUG_SYNC='now SIGNAL select6';
a b
1 2
3 4
5 6
SET DEBUG_SYNC='RESET';
DROP TABLE t1;
|