Debian Codegraph @

mysql-test/suite/perfschema/t/table_plugin_in_use.test

raw
1 ################################################################################
2 # Test case to test functionality in which a plugin/component can add its own
3 # tables in performance schema.
4 #
5 # This test covers various case when the plugin is in use during uninstall
6 #
7 ################################################################################
8
9 --source include/not_asan_mac.inc
10
11 connect(con1, localhost, root,,);
12
13 connect(con2, localhost, root,,);
14
15 connect(mon, localhost, root,,);
16
17 --connection default
18
19 --echo #################
20 --echo # INITIAL STATE #
21 --echo #################
22
23 update performance_schema.setup_objects
24 set ENABLED = "YES", TIMED = "YES"
25 where OBJECT_TYPE = "TABLE" and OBJECT_SCHEMA = "performance_schema";
26
27 FLUSH TABLES;
28
29 select * from INFORMATION_SCHEMA.tables
30 where TABLE_NAME like "pfs_example_%";
31
32 --error ER_NO_SUCH_TABLE
33 describe performance_schema.pfs_example_employee_name;
34
35 --error ER_NO_SUCH_TABLE
36 show create table performance_schema.pfs_example_employee_name;
37
38 --error ER_NO_SUCH_TABLE
39 select * from performance_schema.pfs_example_employee_name;
40
41 --echo ###########
42 --echo # INSTALL #
43 --echo ###########
44 --replace_regex /\.so|\.dll/.xxx/
45 --eval INSTALL PLUGIN pfs_example_plugin_employee SONAME '$PFS_EXAMPLE_PLUGIN_EMPLOYEE'
46
47 select name from mysql.plugin
48 where name like 'pfs_example_%';
49
50 select TABLE_SCHEMA, TABLE_NAME, ENGINE, VERSION, TABLE_COMMENT
51 from INFORMATION_SCHEMA.tables
52 where TABLE_NAME like "pfs_example_%"
53 order by table_name;
54
55 describe performance_schema.pfs_example_employee_name;
56
57 show create table performance_schema.pfs_example_employee_name;
58
59 select * from performance_schema.pfs_example_employee_name;
60
61 --connection con1
62 let $con1_thread_id= `select THREAD_ID from performance_schema.threads
63 where PROCESSLIST_ID = connection_id()`;
64
65 echo "===== In con1 : Issue query";
66 select * from performance_schema.pfs_example_employee_name;
67
68 --connection con2
69 let $con2_thread_id= `select THREAD_ID from performance_schema.threads
70 where PROCESSLIST_ID = connection_id()`;
71
72 echo "===== In con2 : Starting transaction";
73 begin;
74 select * from performance_schema.pfs_example_employee_name;
75
76 --connection default
77 let $con_default_thread_id= `select THREAD_ID from performance_schema.threads
78 where PROCESSLIST_ID = connection_id()`;
79
80 --echo ##############
81 --echo # UN INSTALL #
82 --echo ##############
83
84 echo "===== In default : Sending UNINSTALL";
85 --send
86 UNINSTALL PLUGIN pfs_example_plugin_employee;
87
88 --connection mon
89
90 # Wait for MDL 'EXCLUSIVE' for connection default to appear
91 let $wait_condition= select count(*) = 1
92 from performance_schema.metadata_locks
93 where
94 OBJECT_TYPE='TABLE' and
95 OBJECT_SCHEMA='performance_schema' and
96 OBJECT_NAME="pfs_example_employee_name" and
97 LOCK_TYPE='EXCLUSIVE' and
98 LOCK_DURATION='TRANSACTION' and
99 LOCK_STATUS='PENDING' and
100 OWNER_THREAD_ID=$con_default_thread_id;
101 --source include/wait_condition.inc
102
103 --disable_query_log
104 echo "===== Check table lock status ";
105 select OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME,
106 OWNER_THREAD_ID, INTERNAL_LOCK, EXTERNAL_LOCK
107 from performance_schema.table_handles
108 where OBJECT_NAME like "pfs_example_%";
109
110 echo "===== Check Thread Status for default connection ";
111 eval select NAME, PROCESSLIST_COMMAND, PROCESSLIST_STATE, PROCESSLIST_INFO
112 from performance_schema.threads
113 where NAME = "thread/sql/one_connection"
114 and PROCESSLIST_INFO like "UNINSTALL %" and
115 THREAD_ID = $con_default_thread_id;
116
117 echo "===== Check metadata lock status ";
118 eval select OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME,
119 LOCK_TYPE, LOCK_DURATION, LOCK_STATUS
120 from performance_schema.metadata_locks
121 where OBJECT_NAME like "pfs_example_%"
122 and (OWNER_THREAD_ID = $con_default_thread_id
123 OR OWNER_THREAD_ID = $con1_thread_id
124 OR OWNER_THREAD_ID = $con2_thread_id)
125 order by LOCK_STATUS, LOCK_TYPE;
126 --enable_query_log
127
128 select name from mysql.plugin
129 where name like 'pfs_example_%';
130
131 --connection con1
132
133 echo "===== In con1 : Send a query. About to block";
134 --send
135 select * from performance_schema.pfs_example_employee_name;
136
137 --connection con2
138
139 echo "===== In con2 : Still alive. Issue a query.";
140 select * from performance_schema.pfs_example_employee_name;
141
142 --connection mon
143
144 # Wait for MDL 'SHARED_READ' for connection con1 to appear
145 let $wait_condition= select count(*) = 1
146 from performance_schema.metadata_locks
147 where
148 OBJECT_TYPE='TABLE' and
149 OBJECT_SCHEMA='performance_schema' and
150 OBJECT_NAME="pfs_example_employee_name" and
151 LOCK_TYPE='SHARED_READ' and
152 LOCK_DURATION='TRANSACTION' and
153 LOCK_STATUS='PENDING' and
154 OWNER_THREAD_ID=$con1_thread_id;
155 --source include/wait_condition.inc
156
157 --disable_query_log
158 echo "===== Check table lock status ";
159 select OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME,
160 OWNER_THREAD_ID, INTERNAL_LOCK, EXTERNAL_LOCK
161 from performance_schema.table_handles
162 where OBJECT_NAME like "pfs_example_%";
163
164 echo "===== Check Thread Status for default connection ";
165 eval select NAME, PROCESSLIST_COMMAND, PROCESSLIST_STATE, PROCESSLIST_INFO
166 from performance_schema.threads
167 where NAME = "thread/sql/one_connection"
168 and PROCESSLIST_INFO like "UNINSTALL %" and
169 THREAD_ID = $con_default_thread_id;
170
171 echo "===== Check metadata lock status ";
172 eval select OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME,
173 LOCK_TYPE, LOCK_DURATION, LOCK_STATUS
174 from performance_schema.metadata_locks
175 where OBJECT_NAME like "pfs_example_%"
176 and (OWNER_THREAD_ID = $con_default_thread_id
177 OR OWNER_THREAD_ID = $con1_thread_id
178 OR OWNER_THREAD_ID = $con2_thread_id)
179 order by LOCK_STATUS;
180 --enable_query_log
181
182 --connection con2
183
184 echo "===== In con2 : Closing transaction";
185 commit;
186
187 --echo ########
188 --echo # CON1 #
189 --echo ########
190
191 --connection con1
192 --error ER_NO_SUCH_TABLE
193 --reap
194
195 --echo ########################
196 --echo # UNINSTALL completing #
197 --echo ########################
198
199 --connection default
200 --reap
201
202 select name from mysql.plugin
203 where name like 'pfs_example_%';
204
205 select * from INFORMATION_SCHEMA.tables
206 where TABLE_NAME like "pfs_example_%";
207
208 --error ER_NO_SUCH_TABLE
209 describe performance_schema.pfs_example_employee_name;
210
211 --error ER_NO_SUCH_TABLE
212 show create table performance_schema.pfs_example_employee_name;
213
214 --error ER_NO_SUCH_TABLE
215 select * from performance_schema.pfs_example_employee_name;
216
217 --echo ###############
218 --echo # INSTALL (2) #
219 --echo ###############
220 --replace_regex /\.so|\.dll/.xxx/
221 --eval INSTALL PLUGIN pfs_example_plugin_employee SONAME '$PFS_EXAMPLE_PLUGIN_EMPLOYEE'
222
223 select name from mysql.plugin
224 where name like 'pfs_example_%';
225
226 select TABLE_SCHEMA, TABLE_NAME, ENGINE, VERSION, TABLE_COMMENT
227 from INFORMATION_SCHEMA.tables
228 where TABLE_NAME like "pfs_example_%"
229 order by table_name;
230
231 describe performance_schema.pfs_example_employee_name;
232
233 show create table performance_schema.pfs_example_employee_name;
234
235 select * from performance_schema.pfs_example_employee_name;
236
237 --connection con1
238
239 echo "===== In con1 : Issue query.";
240 select * from performance_schema.pfs_example_employee_name;
241
242 --connection con2
243
244 echo "===== In con2 : Start transaction.";
245 begin;
246 select * from performance_schema.pfs_example_employee_name;
247
248 --connection default
249
250 --echo ##################
251 --echo # UN INSTALL (2) #
252 --echo ##################
253
254 echo "===== In default : Sending UNINSTALL";
255 --send
256 UNINSTALL PLUGIN pfs_example_plugin_employee;
257
258 --connection mon
259
260 # Wait for MDL 'EXCLUSIVE' for connection default to appear
261 let $wait_condition= select count(*) = 1
262 from performance_schema.metadata_locks
263 where
264 OBJECT_TYPE='TABLE' and
265 OBJECT_SCHEMA='performance_schema' and
266 OBJECT_NAME="pfs_example_employee_name" and
267 LOCK_TYPE='EXCLUSIVE' and
268 LOCK_DURATION='TRANSACTION' and
269 LOCK_STATUS='PENDING' and
270 OWNER_THREAD_ID=$con_default_thread_id;
271 --source include/wait_condition.inc
272
273 --disable_query_log
274 echo "===== Check table lock status ";
275 select OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME,
276 OWNER_THREAD_ID, INTERNAL_LOCK, EXTERNAL_LOCK
277 from performance_schema.table_handles
278 where OBJECT_NAME like "pfs_example_%";
279
280 echo "===== Check Thread Status for default connection ";
281 eval select NAME, PROCESSLIST_COMMAND, PROCESSLIST_STATE, PROCESSLIST_INFO
282 from performance_schema.threads
283 where NAME = "thread/sql/one_connection"
284 and PROCESSLIST_INFO like "UNINSTALL %" and
285 THREAD_ID = $con_default_thread_id;
286
287 echo "===== Check metadata lock status ";
288 eval select OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME,
289 LOCK_TYPE, LOCK_DURATION, LOCK_STATUS
290 from performance_schema.metadata_locks
291 where OBJECT_NAME like "pfs_example_%"
292 and (OWNER_THREAD_ID = $con_default_thread_id
293 OR OWNER_THREAD_ID = $con1_thread_id
294 OR OWNER_THREAD_ID = $con2_thread_id)
295 order by LOCK_STATUS;
296 --enable_query_log
297
298 select name from mysql.plugin
299 where name like 'pfs_example_%';
300
301 --connection con1
302
303 echo "===== In con1 : Send query. About to block";
304 --send
305 select * from performance_schema.pfs_example_employee_name;
306
307 --connection con2
308
309 echo "===== In con2 : Still alive. Issue query.";
310 select * from performance_schema.pfs_example_employee_name;
311
312 --connection mon
313
314 # Wait for MDL 'SHARED_READ' for connection con1 to appear
315 let $wait_condition= select count(*) = 1
316 from performance_schema.metadata_locks
317 where
318 OBJECT_TYPE='TABLE' and
319 OBJECT_SCHEMA='performance_schema' and
320 OBJECT_NAME="pfs_example_employee_name" and
321 LOCK_TYPE='SHARED_READ' and
322 LOCK_DURATION='TRANSACTION' and
323 LOCK_STATUS='PENDING' and
324 OWNER_THREAD_ID=$con1_thread_id;
325 --source include/wait_condition.inc
326
327 --disable_query_log
328 echo "===== Check table lock status ";
329 select OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME,
330 OWNER_THREAD_ID, INTERNAL_LOCK, EXTERNAL_LOCK
331 from performance_schema.table_handles
332 where OBJECT_NAME like "pfs_example_%";
333
334 echo "===== Check Thread Status for default connection ";
335 eval select NAME, PROCESSLIST_COMMAND, PROCESSLIST_STATE, PROCESSLIST_INFO
336 from performance_schema.threads
337 where NAME = "thread/sql/one_connection"
338 and PROCESSLIST_INFO like "UNINSTALL %" and
339 THREAD_ID = $con_default_thread_id;
340
341 echo "===== Check metadata lock status ";
342 eval select OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME,
343 LOCK_TYPE, LOCK_DURATION, LOCK_STATUS
344 from performance_schema.metadata_locks
345 where OBJECT_NAME like "pfs_example_%"
346 and (OWNER_THREAD_ID = $con_default_thread_id
347 OR OWNER_THREAD_ID = $con1_thread_id
348 OR OWNER_THREAD_ID = $con2_thread_id)
349 order by LOCK_STATUS;
350
351 --echo #########################
352 --echo # KILLING UNINSTALL (2) #
353 --echo #########################
354
355 eval select PROCESSLIST_ID into @pid
356 from performance_schema.threads
357 where NAME = "thread/sql/one_connection"
358 and PROCESSLIST_INFO like "UNINSTALL %" and
359 THREAD_ID = $con_default_thread_id;
360 --enable_query_log
361
362 kill query @pid;
363
364 # Make sure that UNINSTALL query from connection default has been killed
365 let $wait_condition= select count(*) = 0
366 from performance_schema.threads
367 where NAME = "thread/sql/one_connection"
368 and PROCESSLIST_INFO like "UNINSTALL %" and
369 THREAD_ID = $con_default_thread_id;
370 --source include/wait_condition.inc
371
372 --connection con2
373
374 echo "===== In con2 : Closing transaction";
375 commit;
376
377 --echo ########
378 --echo # CON1 #
379 --echo ########
380
381 --connection con1
382 --reap
383
384 --echo ############################
385 --echo # UNINSTALL (2) completing #
386 --echo ############################
387
388 --connection default
389 --error ER_QUERY_INTERRUPTED
390 --reap
391 show errors;
392
393 select name from mysql.plugin
394 where name like 'pfs_example_%';
395
396 select TABLE_SCHEMA, TABLE_NAME, ENGINE, VERSION, TABLE_COMMENT
397 from INFORMATION_SCHEMA.tables
398 where TABLE_NAME like "pfs_example_%"
399 order by table_name;
400
401 describe performance_schema.pfs_example_employee_name;
402
403 show create table performance_schema.pfs_example_employee_name;
404
405 select * from performance_schema.pfs_example_employee_name;
406
407 --echo ##################
408 --echo # UN INSTALL (3) #
409 --echo ##################
410
411 UNINSTALL PLUGIN pfs_example_plugin_employee;
412
413 select * from INFORMATION_SCHEMA.tables
414 where TABLE_NAME like "pfs_example_%";
415
416 --error ER_NO_SUCH_TABLE
417 describe performance_schema.pfs_example_employee_name;
418
419 --error ER_NO_SUCH_TABLE
420 show create table performance_schema.pfs_example_employee_name;
421
422 --error ER_NO_SUCH_TABLE
423 select * from performance_schema.pfs_example_employee_name;
424
425 --echo ###########
426 --echo # CLEANUP #
427 --echo ###########
428
429 update performance_schema.setup_objects
430 set ENABLED = "NO", TIMED = "NO"
431 where OBJECT_TYPE = "TABLE" and OBJECT_SCHEMA = "performance_schema";
432
433 FLUSH TABLES;
434
435 --disconnect con1
436 --disconnect con2
437 --disconnect mon