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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
connection node_2;
connection node_1;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY DEFAULT 0, f2 char(12));
connection node_1;
SET SESSION wsrep_trx_fragment_size = 1;
START TRANSACTION;
INSERT INTO t1 (f2) VALUES ('a'), ('b');
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
COMMIT;
SELECT COUNT(*) AS expect_0 FROM t1;
expect_0
0
connection node_2;
SELECT COUNT(*) AS expect_0 FROM t1;
expect_0
0
DROP TABLE t1;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY DEFAULT 0, f2 char(12));
connection node_1;
SET SESSION wsrep_trx_fragment_size = 1000;
START TRANSACTION;
INSERT INTO t1 (f2) VALUES ('a'), ('b');
ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
COMMIT;
SELECT COUNT(*) AS expect_0 FROM t1;
expect_0
0
connection node_2;
SELECT COUNT(*) AS expect_0 FROM t1;
expect_0
0
DROP TABLE t1;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY DEFAULT 0, f2 char(12));
connection node_1;
SET SESSION wsrep_trx_fragment_size = 1000;
START TRANSACTION;
INSERT INTO t1 VALUES (1, 'a');
INSERT INTO t1 VALUES (2, 'b');
INSERT INTO t1 (f2) VALUES ('c'), ('d');
ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
COMMIT;
expect (1,'a'), (2, 'b')
SELECT * FROM t1;
f1 f2
1 a
2 b
connection node_2;
expect (1,'a'), (2, 'b')
SELECT * FROM t1;
f1 f2
1 a
2 b
DROP TABLE t1;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY DEFAULT 0, f2 char(12));
connection node_1;
SET SESSION wsrep_trx_fragment_size = 1;
INSERT INTO t1 (f2) VALUES ('a'), ('b');
ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
SELECT COUNT(*) AS expect_0 FROM t1;
expect_0
0
connection node_2;
SELECT COUNT(*) AS expect_0 FROM t1;
expect_0
0
connection node_1;
SET SESSION wsrep_trx_fragment_size = 1000;
INSERT INTO t1 (f2) VALUES ('a'), ('b');
ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
SELECT COUNT(*) AS expect_0 FROM t1;
expect_0
0
connection node_2;
SELECT COUNT(*) AS expect_0 FROM t1;
expect_0
0
DROP TABLE t1;
connection node_1;
CREATE TABLE p(id int primary key, j int) ENGINE=InnoDB;
CREATE TABLE c(id int primary key, fk1 int) ENGINE=InnoDB;
ALTER TABLE c ADD FOREIGN KEY (fk1) references p(id);
INSERT INTO p VALUES(1, 0);
SET SESSION wsrep_trx_fragment_size=1;
START TRANSACTION;
INSERT INTO c VALUES (3,1);
INSERT INTO c VALUES (1,1), (2,2);
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
COMMIT;
SELECT * FROM p;
id j
1 0
SELECT * FROM c;
id fk1
connection node_2;
SELECT * FROM p;
id j
1 0
SELECT * FROM c;
id fk1
DROP TABLE c;
DROP TABLE p;
connection node_1;
CREATE TABLE p(id int primary key, j int) ENGINE=InnoDB;
CREATE TABLE c(id int primary key, fk1 int) ENGINE=InnoDB;
ALTER TABLE c ADD FOREIGN KEY (fk1) references p(id);
INSERT INTO p VALUES(1, 0);
SET SESSION wsrep_trx_fragment_size=1000;
START TRANSACTION;
INSERT INTO c VALUES (3,1);
INSERT INTO c VALUES (1,1), (2,2);
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`c`, CONSTRAINT `c_ibfk_1` FOREIGN KEY (`fk1`) REFERENCES `p` (`id`))
COMMIT;
SELECT * FROM p;
id j
1 0
SELECT * FROM c;
id fk1
3 1
connection node_2;
SELECT * FROM p;
id j
1 0
SELECT * FROM c;
id fk1
3 1
DROP TABLE c;
DROP TABLE p;
|