Debian Codegraph @

mysql-test/suite/perfschema/r/system_events_component.result

raw
1 ## Test the Performance Schema System service
2 ##
3 ## Verify that the SOURCE column in all wait, stage, statement,
4 ## transaction and metadata lock tables is set to NULL after a plugin
5 ## or component is unloaded.
6 ##
7 ## 0. Setup
8 ## 1. Install an example component to generate wait events
9 ## 2. Generate stage, statement and transaction events
10 ## 3. Unload the component / component
11 ## 4. Verify that the SOURCE column is null in relevant tables
12 ## 5. Re-install the test plugin
13 ## 6. Verify that the SOURCE column is re-enabled
14 ## 7. Cleanup
15
16 #
17 # 0) Setup
18 #
19 Connection default
20 USE performance_schema;
21
22 # Disable all events from the control thread.
23 UPDATE performance_schema.threads SET instrumented = 'NO' WHERE processlist_id = CONNECTION_ID();
24
25 # Disable all events.
26 UPDATE performance_schema.setup_instruments SET enabled = 'NO', timed = 'NO';
27
28 # Clear the tables that have a SOURCE column.
29 TRUNCATE events_waits_current;
30 TRUNCATE events_waits_history;
31 TRUNCATE events_waits_history_long;
32 TRUNCATE events_stages_current;
33 TRUNCATE events_stages_history;
34 TRUNCATE events_stages_history_long;
35 TRUNCATE events_statements_current;
36 TRUNCATE events_statements_history;
37 TRUNCATE events_statements_history_long;
38 TRUNCATE events_transactions_current;
39 TRUNCATE events_transactions_history;
40 TRUNCATE events_transactions_history_long;
41 # metadata_locks is not truncatable
42
43 #
44 # 1) Install a component that generates its own wait events.
45 #
46 Connection con0
47 USE test;
48 INSTALL COMPONENT 'file://component_pfs_example';
49
50 Connection default
51
52 # Enable events that record the source file and line.
53 UPDATE performance_schema.setup_instruments SET enabled = 'yes', timed = 'yes'
54 WHERE name LIKE 'stage/%' OR name LIKE 'statement/%' OR name = 'transaction' OR
55 name LIKE '%metadata/sql%' OR name LIKE 'wait/synch/mutex/sql/THD::%';
56
57 Connection con0
58
59 #
60 # 2) Generate wait, stage, statement, transaction and metadata lock events. Keep the transaction open for now.
61 #
62 CREATE TABLE t1 (s1 INT);
63 START TRANSACTION;
64 INSERT INTO t1 VALUES (1), (2), (3);
65
66 Connection default
67
68 # Verify that the component registered and generated the wait events.
69 ## TODO Resolve timing issues with events_waits_history. ##
70 # SELECT (COUNT(*) > 0) AS "Expect 1" FROM performance_schema.events_waits_history WHERE event_name LIKE "%pfs_example%";
71 # SELECT (COUNT(*) > 0) AS "Expect 1" FROM performance_schema.events_waits_history_long WHERE event_name LIKE "%pfs_example%";
72
73 # Verify that each table is non-empty and that the SOURCE columns are populated.
74
75 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_waits_current AS t1 WHERE source <> "";
76 Expect 1
77 1
78 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_waits_history WHERE source <> "";
79 Expect 1
80 1
81 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_waits_history_long WHERE source <> "";
82 Expect 1
83 1
84 # May or may not contain rows, but shares same code path as _history and _history_long
85 # SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_stages_current WHERE source <> "";
86
87 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_stages_history WHERE source <> "";
88 Expect 1
89 1
90 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_stages_history_long WHERE source <> "";
91 Expect 1
92 1
93 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_statements_current WHERE source <> "";
94 Expect 1
95 1
96 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_statements_history WHERE source <> "";
97 Expect 1
98 1
99 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_statements_history_long WHERE source <> "";
100 Expect 1
101 1
102 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_transactions_current WHERE source <> "";
103 Expect 1
104 1
105 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_transactions_history WHERE source <> "";
106 Expect 1
107 1
108 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_transactions_history_long WHERE source <> "";
109 Expect 1
110 1
111 SELECT (COUNT(*) > 0) AS "Expect 1" FROM metadata_locks WHERE object_schema = "test" AND source <> "";
112 Expect 1
113 1
114
115 #
116 # 3) Uninstall the test component to force a reset of the SOURCE columns.
117 #
118 UNINSTALL COMPONENT 'file://component_pfs_example';
119
120 #
121 # 4) Verify that the SOURCE column was reset for all events.
122 #
123 SELECT (COUNT(*) = 0) AS "Expect 1" FROM events_waits_current WHERE source <> "";
124 Expect 1
125 1
126 SELECT (COUNT(*) = 0) AS "Expect 1" FROM events_waits_history WHERE source <> "";
127 Expect 1
128 1
129 SELECT (COUNT(*) = 0) AS "Expect 1" FROM events_waits_history_long WHERE source <> "";
130 Expect 1
131 1
132 # May or may not contain rows, but shares same code path as _history and _history_long
133 # SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_stages_current WHERE source = "";
134
135 # Some stage events occur after the component is unloaded, so confirm that at least some of the SOURCE columns were reset.
136 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_stages_history WHERE source = "";
137 Expect 1
138 1
139 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_stages_history_long WHERE source = "";
140 Expect 1
141 1
142
143 SELECT (COUNT(*) = 0) AS "Expect 1" FROM events_statements_current WHERE source <> "";
144 Expect 1
145 1
146 SELECT (COUNT(*) = 0) AS "Expect 1" FROM events_statements_history WHERE source <> "";
147 Expect 1
148 1
149 SELECT (COUNT(*) = 0) AS "Expect 1" FROM events_statements_history_long WHERE source <> "";
150 Expect 1
151 1
152 SELECT (COUNT(*) = 0) AS "Expect 1" FROM events_transactions_current WHERE source <> "";
153 Expect 1
154 1
155 SELECT (COUNT(*) = 0) AS "Expect 1" FROM events_transactions_history WHERE source <> "";
156 Expect 1
157 1
158 SELECT (COUNT(*) = 0) AS "Expect 1" FROM events_transactions_history_long WHERE source <> "";
159 Expect 1
160 1
161 SELECT (COUNT(*) = 0) AS "Expect 1" FROM metadata_locks WHERE object_schema = "test" AND source <> "";
162 Expect 1
163 1
164
165 Connection con0
166
167 # Commit the open transaction from step 2.
168 COMMIT;
169
170 Connection default
171
172 # Clear tables with SOURCE columns.
173 TRUNCATE events_waits_current;
174 TRUNCATE events_waits_history;
175 TRUNCATE events_waits_history_long;
176 TRUNCATE events_stages_current;
177 TRUNCATE events_stages_history;
178 TRUNCATE events_stages_history_long;
179 TRUNCATE events_statements_current;
180 TRUNCATE events_statements_history;
181 TRUNCATE events_statements_history_long;
182 TRUNCATE events_transactions_current;
183 TRUNCATE events_transactions_history;
184 TRUNCATE events_transactions_history_long;
185 # metadata_locks is not truncatable
186
187 Connection con0
188
189 #
190 # 5) Verify that the SOURCE columns are re-enabled after the reset.
191 #
192
193 # Re-install the component.
194 INSTALL COMPONENT 'file://component_pfs_example';
195
196 # Generate new wait, stage, statement and transaction events. Leave the transaction open.
197 START TRANSACTION;
198 INSERT INTO t1 VALUES (4), (5), (6);
199
200 Connection default
201
202 #
203 # 6) Verify that each table is non-empty and that the SOURCE columns are populated.
204 #
205 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_waits_current AS t1 WHERE source <> "";
206 Expect 1
207 1
208 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_waits_history WHERE source <> "";
209 Expect 1
210 1
211 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_waits_history_long WHERE source <> "";
212 Expect 1
213 1
214 # May or may not contain rows, but shares same code path as _history and _history_long
215 # SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_stages_current WHERE source <> "";
216
217 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_stages_history WHERE source <> "";
218 Expect 1
219 1
220 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_stages_history_long WHERE source <> "";
221 Expect 1
222 1
223 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_statements_current WHERE source <> "";
224 Expect 1
225 1
226 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_statements_history WHERE source <> "";
227 Expect 1
228 1
229 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_statements_history_long WHERE source <> "";
230 Expect 1
231 1
232 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_transactions_current WHERE source <> "";
233 Expect 1
234 1
235 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_transactions_history WHERE source <> "";
236 Expect 1
237 1
238 SELECT (COUNT(*) > 0) AS "Expect 1" FROM events_transactions_history_long WHERE source <> "";
239 Expect 1
240 1
241 SELECT (COUNT(*) > 0) AS "Expect 1" FROM metadata_locks WHERE object_schema = "test" AND source <> "";
242 Expect 1
243 1
244
245 Connection con0
246
247 #
248 # 7) Clean up
249 #
250
251 # Commit the open transaction from step 5.
252 COMMIT;
253
254 Connection default
255 DROP TABLE test.t1;
256 UNINSTALL COMPONENT 'file://component_pfs_example';
257 UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES';