Debian Codegraph @

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

raw
1 #
2 # This test tests the operation of SR transaction replay. If a
3 # potentially conflicting remote transaction arrives at
4 # just the right time during the commit of a local transaction,
5 # the local transaction will be aborted and replayed.
6 #
7 # This test is divided in two sections:
8 # 1) Test the scenario where the last fragment does not have write set
9 # payload, just commit flag is replicated
10 # 2) Test the scenario where the last fragment has write set payload
11 # and commit flag
12
13 --source include/galera_cluster.inc
14 --source include/have_innodb.inc
15 --source include/have_debug_sync.inc
16 --source include/galera_have_debug_sync.inc
17
18 # Control connection for manipulating galera sync points
19 --connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
20 SET SESSION wsrep_sync_wait = 0;
21
22 --connection node_1
23
24 --let $wsrep_local_replays_old = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'`
25
26 CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1));
27
28 #########################################################################
29 #
30 # 1) Replay without commit fragment write set payload
31 #
32 #########################################################################
33
34 INSERT INTO t1 VALUES (1, 'a');
35 INSERT INTO t1 VALUES (2, 'a');
36
37 --connection node_1
38 SET AUTOCOMMIT=ON;
39 SET SESSION wsrep_trx_fragment_size = 1;
40 START TRANSACTION;
41
42 UPDATE t1 SET f2 = 'b' WHERE f1 = 1;
43 SELECT * FROM t1 WHERE f1 = 2 FOR UPDATE;
44
45 #
46 # Block the commit from node_2
47 #
48 --connection node_1a
49 --let $galera_sync_point = apply_monitor_slave_enter_sync
50 --source include/galera_set_sync_point.inc
51
52 #
53 # Issue conflicting UPDATE from node_2 and wait until it hits the
54 # apply monitor (but does not apply yet)
55 #
56 --connection node_2
57 UPDATE t1 SET f2 = 'c' WHERE f1 = 2;
58
59 --connection node_1a
60 --let $galera_sync_point = apply_monitor_slave_enter_sync
61 --source include/galera_wait_sync_point.inc
62
63 #
64 # Set a new sync point to block in local monitor on node_1 commit
65 #
66 --source include/galera_clear_sync_point.inc
67 --let $galera_sync_point = local_monitor_master_enter_sync
68 --source include/galera_set_sync_point.inc
69
70 #
71 # Send the commit on node_1
72 #
73 --connection node_1
74 --send COMMIT
75
76 #
77 # Wait until commit reaches sync point
78 #
79 --connection node_1a
80 SET SESSION wsrep_sync_wait = 0;
81 --let $galera_sync_point = apply_monitor_slave_enter_sync local_monitor_master_enter_sync
82 --source include/galera_wait_sync_point.inc
83
84 #
85 # Release conflicting slave transaction and wait until it has BF
86 # aborted pending COMMIT
87 #
88 --source include/galera_clear_sync_point.inc
89 --let $galera_sync_point = abort_trx_end
90 --source include/galera_set_sync_point.inc
91
92 --let $galera_sync_point = apply_monitor_slave_enter_sync
93 --source include/galera_signal_sync_point.inc
94
95 --let $galera_sync_point = abort_trx_end local_monitor_master_enter_sync
96 --source include/galera_wait_sync_point.inc
97
98 #
99 # Release both threads, local thread will now replay
100 #
101 --source include/galera_clear_sync_point.inc
102 --let $galera_sync_point = abort_trx_end
103 --source include/galera_signal_sync_point.inc
104
105 --let $galera_sync_point = local_monitor_master_enter_sync
106 --source include/galera_signal_sync_point.inc
107
108 #
109 # Commit must succeed
110 #
111 --connection node_1
112 --reap
113
114
115 #
116 # Check the outcome and that wsrep schema SR table is empty
117 #
118 SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'b';
119 SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c';
120
121 SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log;
122
123 #
124 # wsrep_local_replays has increased by 1
125 #
126 --let $wsrep_local_replays_new = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'`
127 --disable_query_log
128 --eval SELECT $wsrep_local_replays_new - $wsrep_local_replays_old = 1 AS wsrep_local_replays;
129 --enable_query_log
130
131 --connection node_2
132 SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'b';
133 SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c';
134
135 SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log;
136
137 DELETE FROM t1;
138
139 #########################################################################
140 #
141 # 2) Replay with commit fragment write set payload
142 #
143 #########################################################################
144
145 INSERT INTO t1 VALUES (1, 'a');
146 INSERT INTO t1 VALUES (2, 'a');
147
148 --connection node_1
149 SET AUTOCOMMIT=ON;
150 SET SESSION wsrep_trx_fragment_size = 1;
151 START TRANSACTION;
152
153 #
154 # Do first update SR on
155 #
156 UPDATE t1 SET f2 = 'x' WHERE f1 = 1;
157
158 #
159 # Disable SR for following statements
160 #
161 SET SESSION wsrep_trx_fragment_size = 0;
162
163 UPDATE t1 SET f2 = 'b' WHERE f1 = 1;
164 SELECT * FROM t1 WHERE f1 = 2 FOR UPDATE;
165
166 #
167 # Block the commit from node_2
168 #
169 --connection node_1a
170 --let $galera_sync_point = apply_monitor_slave_enter_sync
171 --source include/galera_set_sync_point.inc
172
173 #
174 # Issue conflicting UPDATE from node_2 and wait until it hits the
175 # apply monitor (but does not apply yet)
176 #
177 --connection node_2
178 UPDATE t1 SET f2 = 'c' WHERE f1 = 2;
179
180 --connection node_1a
181 --let $galera_sync_point = apply_monitor_slave_enter_sync
182 --source include/galera_wait_sync_point.inc
183
184 #
185 # Set a new sync point to block in local monitor on node_1 commit
186 #
187 --source include/galera_clear_sync_point.inc
188 --let $galera_sync_point = local_monitor_master_enter_sync
189 --source include/galera_set_sync_point.inc
190
191 #
192 # Send the commit on node_1
193 #
194 --connection node_1
195 --send COMMIT
196
197 #
198 # Wait until commit reaches sync point
199 #
200 --connection node_1a
201 SET SESSION wsrep_sync_wait = 0;
202 --let $galera_sync_point = apply_monitor_slave_enter_sync local_monitor_master_enter_sync
203 --source include/galera_wait_sync_point.inc
204
205 #
206 # Release conflicting slave transaction and wait until it has BF
207 # aborted pending COMMIT
208 #
209 --source include/galera_clear_sync_point.inc
210 --let $galera_sync_point = abort_trx_end
211 --source include/galera_set_sync_point.inc
212
213 --let $galera_sync_point = apply_monitor_slave_enter_sync
214 --source include/galera_signal_sync_point.inc
215
216 --let $galera_sync_point = abort_trx_end local_monitor_master_enter_sync
217 --source include/galera_wait_sync_point.inc
218
219 #
220 # Release both threads, local thread will now replay
221 #
222 --source include/galera_clear_sync_point.inc
223 --let $galera_sync_point = abort_trx_end
224 --source include/galera_signal_sync_point.inc
225
226 --let $galera_sync_point = local_monitor_master_enter_sync
227 --source include/galera_signal_sync_point.inc
228
229 #
230 # Commit must succeed
231 #
232 --connection node_1
233 --reap
234
235
236 #
237 # Check the outcome and that wsrep schema SR table is empty
238 #
239 SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'b';
240 SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c';
241
242 SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log;
243
244 #
245 # wsrep_local_replays has increased by 1
246 #
247 --let $wsrep_local_replays_new = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'`
248 --disable_query_log
249 --eval SELECT $wsrep_local_replays_new - $wsrep_local_replays_old = 2 AS wsrep_local_replays;
250 --enable_query_log
251
252 --connection node_2
253 SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'b';
254 SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c';
255
256 SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log;
257
258 DELETE FROM t1;
259
260 DROP TABLE t1;