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
|
--source include/galera_cluster.inc
--source include/have_innodb.inc
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 CHAR(10)) ENGINE=InnoDB;
--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
#
# Test 1: statement rollback is not safe
# (some fragments were already replicated)
#
--connection node_1
SET SESSION wsrep_trx_fragment_size = 1;
START TRANSACTION;
INSERT INTO t1 VALUES (1, 'node1');
--connection node_1a
INSERT INTO t1 VALUES (5, 'node2');
--connection node_1
# If we try to INSERT a duplicate key, ER_LOCK_DEADLOCK is the only possible
# outcome at this point. Notice that ER_DUP_ENTRY is NOT an option here
# because we were forced to rollback the whole transaction (not just the
# statement)
--error ER_LOCK_DEADLOCK
INSERT INTO t1 VALUES (5, 'node1');
SELECT * FROM t1;
#
# Test 2: statement rollback is safe
# (no fragments have been replicated)
#
SET SESSION wsrep_trx_fragment_size = 10000;
START TRANSACTION;
INSERT INTO t1 VALUE (10, 'node1');
SELECT * FROM mysql.wsrep_streaming_log;
--connection node_1a
INSERT INTO t1 VALUES(15, 'node2');
--connection node_1
SELECT * FROM t1;
# This time, only the statement is rolled back and we expect ER_DUP_ENTRY.
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES(15, 'node1');
COMMIT;
SELECT * FROM t1;
DROP TABLE t1;
|