blob: 8ed1a3a077e2e5fadcf4686eb7e1f761ac4a05c9 (
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
|
connection node_2;
connection node_1;
connection node_1;
CREATE TABLE t1 (
f1 VARCHAR(255) PRIMARY KEY
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO t1 VALUES ('текст');
connection node_2;
SELECT f1 = 'текст' FROM t1;
f1 = 'текст'
1
connection node_1;
SET AUTOCOMMIT=OFF;
START TRANSACTION;
UPDATE t1 SET f1 = 'текст2';
connection node_2;
SET AUTOCOMMIT=OFF;
START TRANSACTION;
UPDATE t1 SET f1 = 'текст3';
connection node_1;
COMMIT;
connection node_2;
COMMIT;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
SELECT f1 = 'текст2' FROM t1;
f1 = 'текст2'
1
SELECT f1 = 'текст2' FROM t1 WHERE f1 = 'текст2';
f1 = 'текст2'
1
connection node_2;
START TRANSACTION;
INSERT INTO t1 VALUES ('текст4');
connection node_1;
START TRANSACTION;
INSERT INTO t1 VALUES ('текст4');
connection node_2;
COMMIT;
connection node_1;
COMMIT;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
COMMIT;
DROP TABLE t1;
|