Debian Codegraph @

mysql-test/suite/group_replication/t/gr_consistent_transactions_prepared_psi_memory.test

raw
1 ################################################################################
2 # This test verifies following for 'consistent_transactions_prepared'
3 # and 'consistent_transactions_waiting' event:
4 # - Verify that entries corresponding to the
5 # 'consistent_transactions_prepared' and
6 # 'consistent_transactions_waiting' performance schema
7 # instrumented memory are in the memory table only during the
8 # execution of the group replication plugin.
9 # - Verify that the sum of bytes allocated is greater than zero for a
10 # transaction and zero after transaction is finished.
11 #
12 # Test:
13 # 0. The test requires two servers: M1 and M2.
14 # 1. Verify that the entries corresponding to the
15 # instrumented memory are in the setup instruments
16 # table and the memory summary tables for the event
17 # consistent_transactions_prepared.
18 # 2. Verify that the entries corresponding to the
19 # instrumented memory are in the setup instruments
20 # table and the memory summary tables for the event
21 # consistent_transactions_waiting.
22 # 3. Create two tables on the group.
23 # 4. Lock table t1 on server2 to block a future update.
24 # 5. Execute transaction T1, the transaction will block on
25 # server2 due to the table lock.
26 # 6. Wait until T1 is delivered to server2.
27 # 7. Execute a write transaction T2 on server2 with
28 # group_replication_consistency= 'BEFORE_AND_AFTER' , it
29 # will wait for T1 commit and will make new transactions
30 # wait for T2.
31 # 8. Force server1 to block between T2 prepare and commit.
32 # 9. Unblock T1 on server2.
33 # 10. Wait until T2 reaches prepare on server1 and then
34 # verify that the number of bytes allocated for
35 # consistent_members_that_prepare_transaction
36 # event is greater than 0.
37 # 11. Now that T2 is prepared on server1 but it is not yet
38 # committed, new transactions (T3) are hold on server1.
39 # Also it verifies that the number of bytes allocated
40 # for consistent_transactions_waiting event is
41 # greater than 0.
42 # 12. Unblock T2 prepare on server1.
43 # 13. Validate data.
44 # 14. Clean up and stop GR on server 1.
45 # 15. Verify that the entries corresponding to the instrumented
46 # consistent_transactions_prepared remain in the
47 # tables after stopping GR.
48 # 16. Verify that the entries corresponding to the instrumented
49 # consistent_transactions_waiting remain in the
50 # tables after stopping GR.
51 # 17. Verify that the number of bytes allocated for
52 # consistent_transactions_prepared
53 # event must be 0.
54 # 18. Verify that the number of bytes allocated for
55 # consistent_transactions_waiting
56 # event must be 0.
57 # 19. Clean up.
58 ################################################################################
59 --source include/have_debug_sync.inc
60 --source include/have_group_replication_plugin.inc
61 --source include/group_replication.inc
62
63
64 --echo
65 --echo ############################################################
66 --echo # 1. Verify that the entries corresponding to the
67 --echo # instrumented memory are in the setup instruments
68 --echo # table and the memory summary tables for the event
69 --echo # consistent_transactions_prepared.
70 SELECT * FROM performance_schema.setup_instruments WHERE NAME LIKE 'memory/group_rpl/consistent_transactions_prepared';
71 --let $assert_text= 'There should be 1 entry corresponding to the consistent_transactions_prepared in the setup_instruments table after starting GR'
72 --let $assert_cond= COUNT(*) = 1 FROM performance_schema.setup_instruments WHERE NAME LIKE "memory/group_rpl/consistent_transactions_prepared"
73 --source include/assert.inc
74
75 SELECT EVENT_NAME FROM performance_schema.memory_summary_global_by_event_name WHERE EVENT_NAME LIKE 'memory/group_rpl/consistent_transactions_prepared';
76 --let $assert_text= 'There should be 1 entry corresponding to the consistent_transactions_prepared in the memory_summary_global_by_event_name table after starting GR'
77 --let $assert_cond= COUNT(*) = 1 FROM performance_schema.memory_summary_global_by_event_name WHERE EVENT_NAME LIKE "memory/group_rpl/consistent_transactions_prepared"
78 --source include/assert.inc
79
80
81 --echo
82 --echo ############################################################
83 --echo # 2. Verify that the entries corresponding to the
84 --echo # instrumented memory are in the setup instruments
85 --echo # table and the memory summary tables for the event
86 --echo # consistent_transactions_waiting.
87 SELECT * FROM performance_schema.setup_instruments WHERE NAME LIKE 'memory/group_rpl/consistent_transactions_waiting';
88 --let $assert_text= 'There should be 1 entry corresponding to the consistent_transactions_waiting in the setup_instruments table after starting GR'
89 --let $assert_cond= COUNT(*) = 1 FROM performance_schema.setup_instruments WHERE NAME LIKE "memory/group_rpl/consistent_transactions_waiting"
90 --source include/assert.inc
91
92 SELECT EVENT_NAME FROM performance_schema.memory_summary_global_by_event_name WHERE EVENT_NAME LIKE 'memory/group_rpl/consistent_transactions_waiting';
93 --let $assert_text= 'There should be 1 entry corresponding to the consistent_transactions_waiting in the memory_summary_global_by_event_name table after starting GR'
94 --let $assert_cond= COUNT(*) = 1 FROM performance_schema.memory_summary_global_by_event_name WHERE EVENT_NAME LIKE "memory/group_rpl/consistent_transactions_waiting"
95 --source include/assert.inc
96
97
98 --echo
99 --echo ############################################################
100 --echo # 3. Create two tables on the group.
101 --let $rpl_connection_name= server1
102 --source include/rpl_connection.inc
103 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY);
104 CREATE TABLE t2 (c1 INT NOT NULL PRIMARY KEY);
105 --source include/rpl_sync.inc
106
107
108 --echo
109 --echo ############################################################
110 --echo # 4. Lock table t1 on server2 to block a future update.
111 --let $rpl_connection_name= server_2
112 --source include/rpl_connection.inc
113 LOCK table t1 READ;
114
115
116 --echo
117 --echo ############################################################
118 --echo # 5. Execute transaction T1, the transaction will block on
119 --echo # server2 due to the table lock.
120 --let $rpl_connection_name= server1
121 --source include/rpl_connection.inc
122 BEGIN;
123 INSERT INTO t1 VALUES (1);
124 INSERT INTO t2 VALUES (1);
125 COMMIT;
126
127
128 --echo
129 --echo ############################################################
130 --echo # 6. Wait until T1 is delivered to server2.
131 --let $rpl_connection_name= server2
132 --source include/rpl_connection.inc
133 --let $member2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
134 --let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.replication_group_member_stats WHERE member_id='$member2_uuid' AND count_transactions_checked=3 AND count_transactions_remote_in_applier_queue=1
135 --source include/wait_condition.inc
136
137
138 --echo
139 --echo ############################################################
140 --echo # 7. Execute a write transaction T2 on server2 with
141 --echo # group_replication_consistency= 'BEFORE_AND_AFTER' , it
142 --echo # will wait for T1 commit and will make new transactions
143 --echo # wait for T2.
144 --let $rpl_connection_name= server_2_1
145 --source include/rpl_connection.inc
146 SET @@SESSION.group_replication_consistency= 'BEFORE_AND_AFTER';
147 --send UPDATE t2 SET c1=99 WHERE c1=1
148
149 --let $rpl_connection_name= server2
150 --source include/rpl_connection.inc
151 --let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist WHERE state='Executing hook on transaction begin.' AND info='UPDATE t2 SET c1=99 WHERE c1=1'
152 --source include/wait_condition.inc
153
154
155 --echo
156 --echo ############################################################
157 --echo # 8. Force server1 to block between T2 prepare and commit.
158 --let $rpl_connection_name= server_1
159 --source include/rpl_connection.inc
160 SET @@GLOBAL.DEBUG= '+d,group_replication_wait_on_after_applier_prepare';
161
162
163 --echo
164 --echo ############################################################
165 --echo # 9. Unblock T1 on server2.
166 --let $rpl_connection_name= server_2
167 --source include/rpl_connection.inc
168 UNLOCK TABLES;
169
170 --let $rpl_connection_name= server_2_1
171 --source include/rpl_connection.inc
172 # Get transaction T1 outcome.
173 --reap
174 SET @@SESSION.group_replication_consistency= DEFAULT;
175
176
177 --echo
178 --echo ############################################################
179 --echo # 10. Wait until T2 reaches prepare on server1 and then
180 --echo # verify that the number of bytes allocated for
181 --echo # consistent_members_that_prepare_transaction
182 --echo # event is greater than 0.
183 --let $rpl_connection_name= server_1
184 --source include/rpl_connection.inc
185 SET DEBUG_SYNC= "now WAIT_FOR signal.after_applier_prepare_waiting";
186
187 --let $assert_text= 'The sum of bytes allocated must be greater than 0'
188 --let $assert_cond= [SELECT CURRENT_NUMBER_OF_BYTES_USED FROM performance_schema.memory_summary_global_by_event_name WHERE EVENT_NAME LIKE "memory/group_rpl/consistent_transactions_prepared"] > 0
189 --source include/assert.inc
190
191
192 --echo
193 --echo ############################################################
194 --echo # 11. Now that T2 is prepared on server1 but it is not yet
195 --echo # committed, new transactions (T3) are hold on server1.
196 --echo # Also it verifies that the number of bytes allocated
197 --echo # for consistent_transactions_waiting event is
198 --echo # greater than 0.
199 --let $rpl_connection_name= server_1_1
200 --source include/rpl_connection.inc
201 --send SELECT COUNT(*) AS count FROM t2 WHERE c1=99
202
203 # server1 is waiting for T2 to commit
204 --let $rpl_connection_name= server1
205 --source include/rpl_connection.inc
206 --let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist WHERE user='root' AND state='Executing hook on transaction begin.' AND info="SELECT COUNT(*) AS count FROM t2 WHERE c1=99"
207 --source include/wait_condition.inc
208
209 --let $assert_text= 'The sum of bytes allocated must be greater than 0'
210 --let $assert_cond= [SELECT CURRENT_NUMBER_OF_BYTES_USED FROM performance_schema.memory_summary_global_by_event_name WHERE EVENT_NAME LIKE "memory/group_rpl/consistent_transactions_waiting"] > 0
211 --source include/assert.inc
212
213
214 --echo
215 --echo ############################################################
216 --echo # 12. Unblock T2 prepare on server1.
217 --let $rpl_connection_name= server_1
218 --source include/rpl_connection.inc
219 # Signal debug sync to continue.
220 SET @@GLOBAL.DEBUG= '-d,group_replication_wait_on_after_applier_prepare';
221 SET DEBUG_SYNC= 'now SIGNAL signal.after_applier_prepare_continue';
222
223 --let $rpl_connection_name= server_1_1
224 --source include/rpl_connection.inc
225 # Get transaction T3 outcome.
226 --reap
227
228
229 --echo
230 --echo ############################################################
231 --echo # 13. Validate data.
232 --let $rpl_connection_name= server1
233 --source include/rpl_connection.inc
234 --let $assert_text= 'There is 1 value in table t1'
235 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE c1=1, count, 1] = 1
236 --source include/assert.inc
237
238 --let $assert_text= 'There is 1 value in table t2'
239 --let $assert_cond= [SELECT COUNT(*) AS count FROM t2 WHERE c1=99, count, 1] = 1
240 --source include/assert.inc
241
242 --let $rpl_connection_name= server2
243 --source include/rpl_connection.inc
244 --let $assert_text= 'There is 1 value in table t1'
245 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE c1=1, count, 1] = 1
246 --source include/assert.inc
247
248 --let $assert_text= 'There is 1 value in table t2'
249 --let $assert_cond= [SELECT COUNT(*) AS count FROM t2 WHERE c1=99, count, 1] = 1
250 --source include/assert.inc
251
252 --let $diff_tables=server1:t1, server2:t1
253 --source include/diff_tables.inc
254
255 --let $diff_tables=server1:t2, server2:t2
256 --source include/diff_tables.inc
257
258
259 --echo
260 --echo ############################################################
261 --echo # 14. Clean up and stop GR on server 1.
262 --let $rpl_connection_name= server1
263 --source include/rpl_connection.inc
264 DROP TABLE t1;
265 DROP TABLE t2;
266 --source include/stop_group_replication.inc
267 --source include/uninstall_group_replication_plugin.inc
268
269 --echo
270 --echo ##############################################################
271 --echo # 15. Verify that the entries corresponding to the instrumented
272 --echo # consistent_transactions_prepared remain in the
273 --echo # tables after stopping GR.
274 SELECT * FROM performance_schema.setup_instruments WHERE NAME LIKE 'memory/group_rpl/consistent_transactions_prepared';
275 --let $assert_text= 'There should be 1 entry corresponding to the consistent_transactions_prepared in the setup_instruments table after stopping GR'
276 --let $assert_cond= COUNT(*) = 1 FROM performance_schema.setup_instruments WHERE NAME LIKE "memory/group_rpl/consistent_transactions_prepared"
277 --source include/assert.inc
278
279 --let $assert_text= 'There should be 1 entry corresponding to the consistent_transactions_prepared in the memory_summary_global_by_event_name table after stopping GR'
280 --let $assert_cond= COUNT(*) = 1 FROM performance_schema.memory_summary_global_by_event_name WHERE EVENT_NAME LIKE "memory/group_rpl/consistent_transactions_prepared"
281 --source include/assert.inc
282
283
284 --echo
285 --echo ##############################################################
286 --echo # 16. Verify that the entries corresponding to the instrumented
287 --echo # consistent_transactions_waiting remain in the
288 --echo # tables after stopping GR.
289 SELECT * FROM performance_schema.setup_instruments WHERE NAME LIKE 'memory/group_rpl/consistent_transactions_waiting';
290 --let $assert_text= 'There should be 1 entry corresponding to the consistent_transactions_waiting in the setup_instruments table after stopping GR'
291 --let $assert_cond= COUNT(*) = 1 FROM performance_schema.setup_instruments WHERE NAME LIKE "memory/group_rpl/consistent_transactions_waiting"
292 --source include/assert.inc
293
294 --let $assert_text= 'There should be 1 entry corresponding to the consistent_transactions_waiting in the memory_summary_global_by_event_name table after stopping GR'
295 --let $assert_cond= COUNT(*) = 1 FROM performance_schema.memory_summary_global_by_event_name WHERE EVENT_NAME LIKE "memory/group_rpl/consistent_transactions_waiting"
296 --source include/assert.inc
297
298
299 --echo
300 --echo #################################################################
301 --echo # 17. Verify that the number of bytes allocated for
302 --echo # consistent_transactions_prepared
303 --echo # event must be 0.
304 --let $assert_text= 'The sum of bytes allocated must be zero after stopping GR'
305 --let $assert_cond= CURRENT_NUMBER_OF_BYTES_USED = 0 FROM performance_schema.memory_summary_global_by_event_name WHERE EVENT_NAME LIKE "memory/group_rpl/consistent_transactions_prepared"
306 --source include/assert.inc
307
308
309 --echo
310 --echo #################################################################
311 --echo # 18. Verify that the number of bytes allocated for
312 --echo # consistent_transactions_waiting
313 --echo # event must be 0.
314 --let $assert_text= 'The sum of bytes allocated must be zero after stopping GR'
315 --let $assert_cond= CURRENT_NUMBER_OF_BYTES_USED = 0 FROM performance_schema.memory_summary_global_by_event_name WHERE EVENT_NAME LIKE "memory/group_rpl/consistent_transactions_waiting"
316 --source include/assert.inc
317
318
319 --echo
320 --echo ############################################################
321 --echo # 19. Clean up.
322 --source include/install_group_replication_plugin.inc
323 --source include/group_replication_end.inc