Debian Codegraph @

mysql-test/suite/galera/t/galera_serializable.test

raw
1 #
2 # Test that the SERIALIZABLE isolation level behaves as expected.
3 # A local serializable transaction is aborted by an incoming remote update
4 #
5 # wsrep_sync_wait does not work well with serializable, see mysql-wsrep#130
6 # hence the need to use --sleep .
7 #
8
9 --source include/galera_cluster.inc
10 --source include/have_innodb.inc
11
12 --connection node_1
13
14 CREATE TABLE t1 (id INT PRIMARY KEY, f2 INTEGER) ENGINE=InnoDB;
15
16 #
17 # Read (local transaction) / Write (remote transaction) conflict
18 #
19
20 SET AUTOCOMMIT=OFF;
21 SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
22 START TRANSACTION;
23
24 SELECT * FROM t1;
25
26 --connection node_2
27 INSERT INTO t1 VALUES (1,1);
28
29 --sleep 2
30 --connection node_1
31 --error ER_LOCK_DEADLOCK
32 SELECT * FROM t1;
33
34 ROLLBACK;
35 DELETE FROM t1;
36
37 #
38 # Write (local transaction) / Write (remote transaction) conflict
39 #
40
41 --connection node_1
42 INSERT INTO t1 VALUES (1,1);
43 START TRANSACTION;
44 SELECT * FROM t1;
45
46 --connection node_2
47 UPDATE t1 SET f2 = 2;
48
49 --sleep 2
50 --connection node_1
51 --error ER_LOCK_DEADLOCK
52 UPDATE t1 SET f2 = 3;
53
54 ROLLBACK;
55 DELETE FROM t1;
56
57 #
58 # Write (local transaction) / Write (remote transaction) conflict
59 # Local transaction writes before remote one.
60 # Nothing special happens here - ordinary deadlock on COMMIT
61 #
62
63 --connection node_1
64 START TRANSACTION;
65
66 --connection node_1
67 INSERT INTO t1 VALUES (1,1);
68
69 --connection node_2
70 INSERT INTO t1 VALUES (1,2);
71
72 --connection node_1
73 --error ER_LOCK_DEADLOCK
74 COMMIT;
75
76 DROP TABLE t1;