Debian Codegraph @

mysql-test/suite/galera_sr/t/mysql-wsrep-features#165.inc

raw
1 # --source include/galera_cluster.inc
2 # --source include/have_debug_sync.inc
3
4 #
5 # This test attempts to catch a race condition between autocommit
6 # transaction and transaction which is rolling back due to
7 # deadlock.
8 #
9 # Test outline:
10 # * Trx 1a makes updates
11 # * SR trx 1b writes a row 3, then makes updates
12 # * AC trx 1c will attempt to write row 3 and will wait for lock
13 # held by 1b
14 # * Sync point is set for 1b to delay SR rollback
15 # * SR trx 1b makes an update which makes it conflict with trx 1a
16 # * Slave shows BF - BF conflict and fails in applying write event
17
18 --connection node_1
19
20 CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 VARCHAR(1)) ENGINE=InnoDB;
21 INSERT INTO t1 VALUES (1, 'x'), (2, 'x'), (4, 'x'), (5, 'x');
22
23 # --connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
24 # --connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1
25 # --connect node_1c, 127.0.0.1, root, , test, $NODE_MYPORT_1
26
27 --connection node_1a
28 START TRANSACTION;
29
30 UPDATE t1 SET f2 = 'a' WHERE f1 = 1;
31 UPDATE t1 SET f2 = 'a' WHERE f1 = 4;
32 UPDATE t1 SET f2 = 'a' WHERE f1 = 5;
33
34
35 --connection node_1b
36 START TRANSACTION;
37 SET SESSION wsrep_trx_fragment_size = 1;
38 INSERT INTO t1 VALUES (3, 'b');
39 UPDATE t1 SET f2 = 'b' WHERE f1 = 2;
40
41 --connection node_2
42 SELECT * FROM t1;
43
44 # Will block, waiting for 1b
45 --connection node_1c
46 SET AUTOCOMMIT=ON;
47 --send INSERT INTO t1 VALUES (3, 'c')
48
49 --connection node_1
50 --let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS;
51 --source include/wait_condition.inc
52
53 --connection node_2
54 SELECT * FROM t1;
55
56 # Will block, waiting for 1b
57 --connection node_1a
58 --send UPDATE t1 SET f2 = 'a' WHERE f1 = 2
59
60 --connection node_1
61 --let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS;
62 --source include/wait_condition.inc
63
64 # Will deadlock
65 --connection node_1b
66 SET DEBUG_SYNC = 'wsrep_before_SR_rollback SIGNAL wait WAIT_FOR continue';
67 --send UPDATE t1 SET f2 = 'b' WHERE f1 = 1
68
69 # Wait until 1b hits rollback
70 --connection node_1
71 SET DEBUG_SYNC = 'now WAIT_FOR wait';
72
73 # UPDATE 12.06.2016: as of recent wsrep API changes, rollbacking thread no
74 # longer queues ROLLBACKs and blocks on ROLLBACK replication before performing
75 # the actual rollback. As a result this test is moot as both node_1a and node_1c
76 # connections are hanging now until sync point is released. Thus sync point
77 # release had to be moved above to release the connections. However it is not
78 # impossible that further changes in the code may reintroduce the race, so
79 # leaving the test as close to original as possible.
80 #
81 # --connection node_1a
82 # --reap
83 # COMMIT;
84 #
85 # --connection node_1c
86 # --reap
87 #
88 # UPDATE t1 SET f2 = 'x' WHERE f1 = 3;
89
90 --connection node_1
91 SET DEBUG_SYNC = 'now SIGNAL continue';
92
93 --connection node_1c
94 --reap
95
96 UPDATE t1 SET f2 = 'x' WHERE f1 = 3;
97
98 --connection node_1a
99 --reap
100 COMMIT;
101
102 --connection node_1b
103 --error ER_LOCK_DEADLOCK
104 --reap
105
106 --connection node_1
107 SELECT * FROM t1;
108 --connection node_2
109 SELECT * FROM t1;
110
111 --connection node_1
112 SET DEBUG_SYNC = 'RESET';
113 DROP TABLE t1;