Debian Codegraph @

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

raw
1 ###############################################################################
2 # This test verifies following for 'transaction_data' event name:
3 # - Verify that entries corresponding to the 'transaction_data'
4 # performance schema instrumented memory are in the memory table only during
5 # the execution of the group replication plugin.
6 # - Verify that the sum of bytes allocated is greater than zero for a
7 # transaction and zero after transaction is finished.
8 #
9 # Test:
10 # 0. The test requires one Server: M1
11 # 1. Verify that the entries corresponding to the
12 # instrumented memory are in the setup instruments
13 # table and the memory summary tables.
14 # 2. Verify that the sum of bytes allocated is greater than
15 # zero for a transaction and zero after transaction is
16 # finished.
17 # 3. Stop GR.
18 # 4. Verify that the entries corresponding to the instrumented
19 # transaction_data remain in the tables after stopping GR.
20 # 5. Assert that the number of bytes allocated for
21 # transaction_data event must be 0.
22 # 6. Cleanup
23 ###############################################################################
24
25 --source include/have_debug_sync.inc
26 --source include/have_group_replication_plugin.inc
27 --source include/group_replication.inc
28
29 --echo
30 --echo ############################################################
31 --echo # 1. Verify that the entries corresponding to the
32 --echo # instrumented memory are in the setup instruments
33 --echo # table and the memory summary tables.
34 SELECT * FROM performance_schema.setup_instruments WHERE NAME LIKE 'memory/group_rpl/transaction_data';
35 --let $assert_text= 'There should be 1 entry corresponding to the transaction_data in the setup_instruments table after starting GR'
36 --let $assert_cond= COUNT(*) = 1 FROM performance_schema.setup_instruments WHERE NAME LIKE "memory/group_rpl/transaction_data"
37 --source include/assert.inc
38 SELECT EVENT_NAME FROM performance_schema.memory_summary_global_by_event_name WHERE EVENT_NAME LIKE 'memory/group_rpl/transaction_data';
39 --let $assert_text= 'There should be 1 entry corresponding to the transaction_data in the memory_summary_global_by_event_name table after starting GR'
40 --let $assert_cond= COUNT(*) = 1 FROM performance_schema.memory_summary_global_by_event_name WHERE EVENT_NAME LIKE "memory/group_rpl/transaction_data"
41 --source include/assert.inc
42
43
44 --echo
45 --echo ############################################################
46 --echo # 2. Verify that the sum of bytes allocated is greater than
47 --echo # zero for a transaction and zero after transaction is
48 --echo # finished.
49 CREATE TABLE t1(c1 INT PRIMARY KEY) ENGINE=innodb;
50 SET @@GLOBAL.DEBUG= '+d,group_replication_apply_data_packet_after_inject';
51 --send INSERT INTO t1 VALUES(1);
52
53 --let $rpl_connection_name= server_1
54 --source include/rpl_connection.inc
55 SET DEBUG_SYNC= "now WAIT_FOR signal.group_replication_apply_data_packet_after_inject_reached";
56
57 --let $assert_text= 'The sum of bytes allocated must be greater than 0'
58 --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/transaction_data"] > 0
59 --source include/assert.inc
60
61 SET @@GLOBAL.DEBUG= '-d,group_replication_apply_data_packet_after_inject';
62 SET DEBUG_SYNC= "now SIGNAL signal.group_replication_apply_data_packet_after_inject_continue";
63
64 --let $rpl_connection_name= server1
65 --source include/rpl_connection.inc
66 --reap
67
68 DROP TABLE t1;
69
70
71 --echo
72 --echo ############################################################
73 --echo # 3. Stop GR
74 --source include/stop_group_replication.inc
75
76
77 --echo
78 --echo ##############################################################
79 --echo # 4. Verify that the entries corresponding to the instrumented
80 --echo # transaction_data remain in the tables after stopping GR.
81 SELECT * FROM performance_schema.setup_instruments WHERE NAME LIKE 'memory/group_rpl/transaction_data';
82 --let $assert_text= 'There should be 1 entry corresponding to the transaction_data in the setup_instruments table after stopping GR'
83 --let $assert_cond= COUNT(*) = 1 FROM performance_schema.setup_instruments WHERE NAME LIKE "memory/group_rpl/transaction_data"
84 --source include/assert.inc
85
86 SELECT EVENT_NAME, CURRENT_NUMBER_OF_BYTES_USED FROM performance_schema.memory_summary_global_by_event_name WHERE EVENT_NAME LIKE 'memory/group_rpl/transaction_data';
87 --let $assert_text= 'There should be 1 entry corresponding to the transaction_data in the memory_summary_global_by_event_name table after stopping GR'
88 --let $assert_cond= COUNT(*) = 1 FROM performance_schema.memory_summary_global_by_event_name WHERE EVENT_NAME LIKE "memory/group_rpl/transaction_data"
89 --source include/assert.inc
90
91
92 --echo
93 --echo #################################################################
94 --echo # 5. Assert that the number of bytes allocated for
95 --echo # transaction_data event must be 0.
96 --let $assert_text= 'The sum of bytes allocated must be zero after stopping GR'
97 --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/transaction_data"
98 --source include/assert.inc
99
100
101 --echo
102 --echo #################################################################
103 --echo # 6. Cleanup
104 --source include/group_replication_end.inc