Debian Codegraph @

mysql-test/suite/galera_sr/t/galera_sr_rollback_statement.test

raw
1 #
2 # Test the case where a statement is rolled back due to an error while
3 # Streaming Replication is in effect. We construct an INSERT ... SELECT
4 # statement that will fail with a duplicate key error towards the end of
5 # the statement, after a portion has already been replicated via SR.
6 #
7 --source include/galera_cluster.inc
8 --source include/have_innodb.inc
9
10 --connection node_1
11
12 CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR) ENGINE=InnoDB;
13 CREATE TABLE t2 (f1 INTEGER PRIMARY KEY, f2 CHAR) ENGINE=InnoDB;
14
15 INSERT INTO t1 VALUES (1, 'a'), (2, 'a'), (3, 'a');
16
17 # This poison value is used to cause the INSERT ... SELECT below to fail
18 INSERT INTO t2 VALUES (3, 'b');
19
20 SET SESSION wsrep_trx_fragment_size = 1;
21
22 --disable_query_log
23 --let $last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
24 --enable_query_log
25
26 --error ER_DUP_ENTRY
27 INSERT INTO t2 SELECT * FROM t1;
28
29 #
30 # We should see three fragments replicated: Rows 1, 2 and rollback fragment.
31 #
32 --disable_query_log
33 --let $last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'`
34 --eval SELECT $last_committed_after - $last_committed_before AS last_committed_diff
35 --enable_query_log
36
37 --connection node_2
38 --let $wait_condition = SELECT COUNT(*) = 1 FROM t2;
39 --source include/wait_condition.inc
40
41 # Cluster continues to operate after the implicit ROLLBACK;
42 --connection node_1
43 INSERT INTO t2 VALUES (1, 'c');
44
45 --connection node_2
46 INSERT INTO t2 VALUES (2, 'c');
47
48 --connection node_1
49 SELECT * FROM t2;
50
51 --connection node_2
52 SELECT * FROM t2;
53
54 --connection node_1
55
56 SET SESSION wsrep_trx_fragment_size = DEFAULT;
57
58 DROP TABLE t1;
59 DROP TABLE t2;