1 # Tests for the performance schema
3 # =======================================
4 # HELPER include/event_aggregate_load.inc
5 # =======================================
7 echo
"================== Step 1 ==================";
9 execute dump_waits_account;
10 execute dump_waits_user;
11 execute dump_waits_host;
12 execute dump_waits_global;
13 execute dump_waits_history;
14 execute dump_stages_account;
15 execute dump_stages_user;
16 execute dump_stages_host;
17 execute dump_stages_global;
18 execute dump_stages_history;
19 execute dump_statements_account;
20 execute dump_statements_user;
21 execute dump_statements_host;
22 execute dump_statements_global;
23 execute dump_statements_history;
24 execute dump_accounts;
28 # Notes about this test
30 # Each connect causes 2 wait/synch/mutex/sql/LOCK_connection_count events:
31 # - 1 in mysqld.cc, create_new_thread(), for the main thread
32 # - 1 in sql_connect.cc, check_user(), for the connected thread
33 # The main thread does not count for BY_ACCOUNT / BY_HOST.
34 # The user thread does count for BY_ACCOUNT, BY_HOST
36 # Each get_lock() causes 1 wait/synch/mutex/sql/LOCK_user_locks
38 # To avoid noise from main, the background threads are disabled.
40 connect (con1, localhost, user1, , );
42 echo
"================== con1 connected ==================";
46 # Wait for the connect to complete
48 select count(*) = 1 from performance_schema.threads
49 where `TYPE`=
'FOREGROUND' and PROCESSLIST_USER=
'user1';
50 --source include/wait_condition.inc
52 echo
"================== Step 2 ==================";
54 execute dump_waits_account;
55 execute dump_waits_user;
56 execute dump_waits_host;
57 execute dump_waits_global;
58 execute dump_waits_history;
59 execute dump_stages_account;
60 execute dump_stages_user;
61 execute dump_stages_host;
62 execute dump_stages_global;
63 execute dump_stages_history;
64 execute dump_statements_account;
65 execute dump_statements_user;
66 execute dump_statements_host;
67 execute dump_statements_global;
68 execute dump_statements_history;
69 execute dump_accounts;
75 select get_lock(
"marker", 10);
76 select release_lock(
"marker");
77 insert into
test.t1 values (
"marker");
79 echo
"================== con1 marker ==================";
83 # Wait for the payload to complete
85 select count(*) = 1 from performance_schema.events_waits_current
86 where EVENT_NAME=
'idle';
87 --source include/wait_condition.inc
89 echo
"================== Step 3 ==================";
91 execute dump_waits_account;
92 execute dump_waits_user;
93 execute dump_waits_host;
94 execute dump_waits_global;
95 execute dump_waits_history;
96 execute dump_stages_account;
97 execute dump_stages_user;
98 execute dump_stages_host;
99 execute dump_stages_global;
100 execute dump_stages_history;
101 execute dump_statements_account;
102 execute dump_statements_user;
103 execute dump_statements_host;
104 execute dump_statements_global;
105 execute dump_statements_history;
106 execute dump_accounts;
111 # select * from performance_schema.events_waits_history_long;
112 # select PROCESSLIST_USER, PROCESSLIST_HOST, INSTRUMENTED from performance_schema.threads;
114 connect (con2, localhost, user2, , );
116 echo
"================== con2 connected ==================";
120 # Wait for the connect to complete
122 select count(*) = 1 from performance_schema.threads
123 where `TYPE`=
'FOREGROUND' and PROCESSLIST_USER=
'user2';
124 --source include/wait_condition.inc
126 echo
"================== Step 4 ==================";
128 execute dump_waits_account;
129 execute dump_waits_user;
130 execute dump_waits_host;
131 execute dump_waits_global;
132 execute dump_waits_history;
133 execute dump_stages_account;
134 execute dump_stages_user;
135 execute dump_stages_host;
136 execute dump_stages_global;
137 execute dump_stages_history;
138 execute dump_statements_account;
139 execute dump_statements_user;
140 execute dump_statements_host;
141 execute dump_statements_global;
142 execute dump_statements_history;
143 execute dump_accounts;
149 select get_lock(
"marker", 10);
150 select release_lock(
"marker");
151 insert into
test.t1 values (
"marker");
153 echo
"================== con2 marker ==================";
157 # Wait for the payload to complete
159 select count(*) = 2 from performance_schema.events_waits_current
160 where EVENT_NAME=
'idle';
161 --source include/wait_condition.inc
163 echo
"================== Step 5 ==================";
165 execute dump_waits_account;
166 execute dump_waits_user;
167 execute dump_waits_host;
168 execute dump_waits_global;
169 execute dump_waits_history;
170 execute dump_stages_account;
171 execute dump_stages_user;
172 execute dump_stages_host;
173 execute dump_stages_global;
174 execute dump_stages_history;
175 execute dump_statements_account;
176 execute dump_statements_user;
177 execute dump_statements_host;
178 execute dump_statements_global;
179 execute dump_statements_history;
180 execute dump_accounts;
184 connect (con3, localhost, user3, , );
186 echo
"================== con3 connected ==================";
190 # Wait for the connect to complete
192 select count(*) = 1 from performance_schema.threads
193 where `TYPE`=
'FOREGROUND' and PROCESSLIST_USER=
'user3';
194 --source include/wait_condition.inc
196 echo
"================== Step 6 ==================";
198 execute dump_waits_account;
199 execute dump_waits_user;
200 execute dump_waits_host;
201 execute dump_waits_global;
202 execute dump_waits_history;
203 execute dump_stages_account;
204 execute dump_stages_user;
205 execute dump_stages_host;
206 execute dump_stages_global;
207 execute dump_stages_history;
208 execute dump_statements_account;
209 execute dump_statements_user;
210 execute dump_statements_host;
211 execute dump_statements_global;
212 execute dump_statements_history;
213 execute dump_accounts;
219 select get_lock(
"marker", 10);
220 select release_lock(
"marker");
221 insert into
test.t1 values (
"marker");
223 echo
"================== con3 marker ==================";
227 # Wait for the payload to complete
229 select count(*) = 3 from performance_schema.events_waits_current
230 where EVENT_NAME=
'idle';
231 --source include/wait_condition.inc
233 echo
"================== Step 7 ==================";
235 execute dump_waits_account;
236 execute dump_waits_user;
237 execute dump_waits_host;
238 execute dump_waits_global;
239 execute dump_waits_history;
240 execute dump_stages_account;
241 execute dump_stages_user;
242 execute dump_stages_host;
243 execute dump_stages_global;
244 execute dump_stages_history;
245 execute dump_statements_account;
246 execute dump_statements_user;
247 execute dump_statements_host;
248 execute dump_statements_global;
249 execute dump_statements_history;
250 execute dump_accounts;
254 connect (con4, localhost, user4, , );
256 echo
"================== con4 connected ==================";
260 # Wait for the connect to complete
262 select count(*) = 1 from performance_schema.threads
263 where `TYPE`=
'FOREGROUND' and PROCESSLIST_USER=
'user4';
264 --source include/wait_condition.inc
266 echo
"================== Step 8 ==================";
268 execute dump_waits_account;
269 execute dump_waits_user;
270 execute dump_waits_host;
271 execute dump_waits_global;
272 execute dump_waits_history;
273 execute dump_stages_account;
274 execute dump_stages_user;
275 execute dump_stages_host;
276 execute dump_stages_global;
277 execute dump_stages_history;
278 execute dump_statements_account;
279 execute dump_statements_user;
280 execute dump_statements_host;
281 execute dump_statements_global;
282 execute dump_statements_history;
283 execute dump_accounts;
289 select get_lock(
"marker", 10);
290 select release_lock(
"marker");
291 insert into
test.t1 values (
"marker");
293 echo
"================== con4 marker ==================";
297 # Wait for the payload to complete
299 select count(*) = 4 from performance_schema.events_waits_current
300 where EVENT_NAME=
'idle';
301 --source include/wait_condition.inc
303 echo
"================== Step 9 ==================";
305 execute dump_waits_account;
306 execute dump_waits_user;
307 execute dump_waits_host;
308 execute dump_waits_global;
309 execute dump_waits_history;
310 execute dump_stages_account;
311 execute dump_stages_user;
312 execute dump_stages_host;
313 execute dump_stages_global;
314 execute dump_stages_history;
315 execute dump_statements_account;
316 execute dump_statements_user;
317 execute dump_statements_host;
318 execute dump_statements_global;
319 execute dump_statements_history;
320 execute dump_accounts;
328 # Wait for the disconnect to complete
330 select count(*) = 0 from performance_schema.threads
331 where `TYPE`=
'FOREGROUND' and PROCESSLIST_USER=
'user1';
332 --source include/wait_condition.inc
334 echo
"================== con1 disconnected ==================";
336 echo
"================== Step 10 ==================";
338 execute dump_waits_account;
339 execute dump_waits_user;
340 execute dump_waits_host;
341 execute dump_waits_global;
342 execute dump_waits_history;
343 execute dump_stages_account;
344 execute dump_stages_user;
345 execute dump_stages_host;
346 execute dump_stages_global;
347 execute dump_stages_history;
348 execute dump_statements_account;
349 execute dump_statements_user;
350 execute dump_statements_host;
351 execute dump_statements_global;
352 execute dump_statements_history;
353 execute dump_accounts;
361 # Wait for the disconnect to complete
363 select count(*) = 0 from performance_schema.threads
364 where `TYPE`=
'FOREGROUND' and PROCESSLIST_USER=
'user2';
365 --source include/wait_condition.inc
367 echo
"================== con2 disconnected ==================";
369 echo
"================== Step 11 ==================";
371 execute dump_waits_account;
372 execute dump_waits_user;
373 execute dump_waits_host;
374 execute dump_waits_global;
375 execute dump_waits_history;
376 execute dump_stages_account;
377 execute dump_stages_user;
378 execute dump_stages_host;
379 execute dump_stages_global;
380 execute dump_stages_history;
381 execute dump_statements_account;
382 execute dump_statements_user;
383 execute dump_statements_host;
384 execute dump_statements_global;
385 execute dump_statements_history;
386 execute dump_accounts;
394 # Wait for the disconnect to complete
396 select count(*) = 0 from performance_schema.threads
397 where `TYPE`=
'FOREGROUND' and PROCESSLIST_USER=
'user3';
398 --source include/wait_condition.inc
400 echo
"================== con3 disconnected ==================";
402 echo
"================== Step 12 ==================";
404 execute dump_waits_account;
405 execute dump_waits_user;
406 execute dump_waits_host;
407 execute dump_waits_global;
408 execute dump_waits_history;
409 execute dump_stages_account;
410 execute dump_stages_user;
411 execute dump_stages_host;
412 execute dump_stages_global;
413 execute dump_stages_history;
414 execute dump_statements_account;
415 execute dump_statements_user;
416 execute dump_statements_host;
417 execute dump_statements_global;
418 execute dump_statements_history;
419 execute dump_accounts;
427 # Wait for the disconnect to complete
429 select count(*) = 0 from performance_schema.threads
430 where `TYPE`=
'FOREGROUND' and PROCESSLIST_USER=
'user4';
431 --source include/wait_condition.inc
433 echo
"================== con4 disconnected ==================";
435 echo
"================== Step 13 ==================";
437 execute dump_waits_account;
438 execute dump_waits_user;
439 execute dump_waits_host;
440 execute dump_waits_global;
441 execute dump_waits_history;
442 execute dump_stages_account;
443 execute dump_stages_user;
444 execute dump_stages_host;
445 execute dump_stages_global;
446 execute dump_stages_history;
447 execute dump_statements_account;
448 execute dump_statements_user;
449 execute dump_statements_host;
450 execute dump_statements_global;
451 execute dump_statements_history;
452 execute dump_accounts;
458 truncate performance_schema.events_waits_summary_by_thread_by_event_name;
460 echo
"================== WAITS_BY_THREAD truncated ==================";
462 echo
"================== Step 14 ==================";
464 execute dump_waits_account;
465 execute dump_waits_user;
466 execute dump_waits_host;
467 execute dump_waits_global;
468 execute dump_waits_history;
469 execute dump_stages_account;
470 execute dump_stages_user;
471 execute dump_stages_host;
472 execute dump_stages_global;
473 execute dump_stages_history;
474 execute dump_statements_account;
475 execute dump_statements_user;
476 execute dump_statements_host;
477 execute dump_statements_global;
478 execute dump_statements_history;
479 execute dump_accounts;
483 truncate performance_schema.events_waits_summary_by_account_by_event_name;
485 echo
"================== WAITS_BY_ACCOUNT truncated ==================";
487 echo
"================== Step 15 ==================";
489 execute dump_waits_account;
490 execute dump_waits_user;
491 execute dump_waits_host;
492 execute dump_waits_global;
493 execute dump_waits_history;
494 execute dump_stages_account;
495 execute dump_stages_user;
496 execute dump_stages_host;
497 execute dump_stages_global;
498 execute dump_stages_history;
499 execute dump_statements_account;
500 execute dump_statements_user;
501 execute dump_statements_host;
502 execute dump_statements_global;
503 execute dump_statements_history;
504 execute dump_accounts;
508 truncate performance_schema.events_waits_summary_by_user_by_event_name;
510 echo
"================== WAITS_BY_USER truncated ==================";
512 echo
"================== Step 16 ==================";
514 execute dump_waits_account;
515 execute dump_waits_user;
516 execute dump_waits_host;
517 execute dump_waits_global;
518 execute dump_waits_history;
519 execute dump_stages_account;
520 execute dump_stages_user;
521 execute dump_stages_host;
522 execute dump_stages_global;
523 execute dump_stages_history;
524 execute dump_statements_account;
525 execute dump_statements_user;
526 execute dump_statements_host;
527 execute dump_statements_global;
528 execute dump_statements_history;
529 execute dump_accounts;
533 truncate performance_schema.events_waits_summary_by_host_by_event_name;
535 echo
"================== WAITS_BY_HOST truncated ==================";
537 echo
"================== Step 17 ==================";
539 execute dump_waits_account;
540 execute dump_waits_user;
541 execute dump_waits_host;
542 execute dump_waits_global;
543 execute dump_waits_history;
544 execute dump_stages_account;
545 execute dump_stages_user;
546 execute dump_stages_host;
547 execute dump_stages_global;
548 execute dump_stages_history;
549 execute dump_statements_account;
550 execute dump_statements_user;
551 execute dump_statements_host;
552 execute dump_statements_global;
553 execute dump_statements_history;
554 execute dump_accounts;
558 truncate performance_schema.events_waits_summary_global_by_event_name;
560 echo
"================== WAITS_GLOBAL truncated ==================";
562 echo
"================== Step 18 ==================";
564 execute dump_waits_account;
565 execute dump_waits_user;
566 execute dump_waits_host;
567 execute dump_waits_global;
568 execute dump_waits_history;
569 execute dump_stages_account;
570 execute dump_stages_user;
571 execute dump_stages_host;
572 execute dump_stages_global;
573 execute dump_stages_history;
574 execute dump_statements_account;
575 execute dump_statements_user;
576 execute dump_statements_host;
577 execute dump_statements_global;
578 execute dump_statements_history;
579 execute dump_accounts;
583 truncate performance_schema.events_stages_summary_by_thread_by_event_name;
585 echo
"================== STAGES_BY_THREAD truncated ==================";
587 echo
"================== Step 19 ==================";
589 execute dump_waits_account;
590 execute dump_waits_user;
591 execute dump_waits_host;
592 execute dump_waits_global;
593 execute dump_waits_history;
594 execute dump_stages_account;
595 execute dump_stages_user;
596 execute dump_stages_host;
597 execute dump_stages_global;
598 execute dump_stages_history;
599 execute dump_statements_account;
600 execute dump_statements_user;
601 execute dump_statements_host;
602 execute dump_statements_global;
603 execute dump_statements_history;
604 execute dump_accounts;
608 truncate performance_schema.events_stages_summary_by_account_by_event_name;
610 echo
"================== STAGES_BY_ACCOUNT truncated ==================";
612 echo
"================== Step 20 ==================";
614 execute dump_waits_account;
615 execute dump_waits_user;
616 execute dump_waits_host;
617 execute dump_waits_global;
618 execute dump_waits_history;
619 execute dump_stages_account;
620 execute dump_stages_user;
621 execute dump_stages_host;
622 execute dump_stages_global;
623 execute dump_stages_history;
624 execute dump_statements_account;
625 execute dump_statements_user;
626 execute dump_statements_host;
627 execute dump_statements_global;
628 execute dump_statements_history;
629 execute dump_accounts;
633 truncate performance_schema.events_stages_summary_by_user_by_event_name;
635 echo
"================== STAGES_BY_USER truncated ==================";
637 echo
"================== Step 21 ==================";
639 execute dump_waits_account;
640 execute dump_waits_user;
641 execute dump_waits_host;
642 execute dump_waits_global;
643 execute dump_waits_history;
644 execute dump_stages_account;
645 execute dump_stages_user;
646 execute dump_stages_host;
647 execute dump_stages_global;
648 execute dump_stages_history;
649 execute dump_statements_account;
650 execute dump_statements_user;
651 execute dump_statements_host;
652 execute dump_statements_global;
653 execute dump_statements_history;
654 execute dump_accounts;
658 truncate performance_schema.events_stages_summary_by_host_by_event_name;
660 echo
"================== STAGES_BY_HOST truncated ==================";
662 echo
"================== Step 22 ==================";
664 execute dump_waits_account;
665 execute dump_waits_user;
666 execute dump_waits_host;
667 execute dump_waits_global;
668 execute dump_waits_history;
669 execute dump_stages_account;
670 execute dump_stages_user;
671 execute dump_stages_host;
672 execute dump_stages_global;
673 execute dump_stages_history;
674 execute dump_statements_account;
675 execute dump_statements_user;
676 execute dump_statements_host;
677 execute dump_statements_global;
678 execute dump_statements_history;
679 execute dump_accounts;
683 truncate performance_schema.events_stages_summary_global_by_event_name;
685 echo
"================== STAGES_GLOBAL truncated ==================";
687 echo
"================== Step 23 ==================";
689 execute dump_waits_account;
690 execute dump_waits_user;
691 execute dump_waits_host;
692 execute dump_waits_global;
693 execute dump_waits_history;
694 execute dump_stages_account;
695 execute dump_stages_user;
696 execute dump_stages_host;
697 execute dump_stages_global;
698 execute dump_stages_history;
699 execute dump_statements_account;
700 execute dump_statements_user;
701 execute dump_statements_host;
702 execute dump_statements_global;
703 execute dump_statements_history;
704 execute dump_accounts;
708 truncate performance_schema.events_statements_summary_by_thread_by_event_name;
710 echo
"================== STATEMENTS_BY_THREAD truncated ==================";
712 echo
"================== Step 24 ==================";
714 execute dump_waits_account;
715 execute dump_waits_user;
716 execute dump_waits_host;
717 execute dump_waits_global;
718 execute dump_waits_history;
719 execute dump_stages_account;
720 execute dump_stages_user;
721 execute dump_stages_host;
722 execute dump_stages_global;
723 execute dump_stages_history;
724 execute dump_statements_account;
725 execute dump_statements_user;
726 execute dump_statements_host;
727 execute dump_statements_global;
728 execute dump_statements_history;
729 execute dump_accounts;
733 truncate performance_schema.events_statements_summary_by_account_by_event_name;
735 echo
"================== STATEMENTS_BY_ACCOUNT truncated ==================";
737 echo
"================== Step 25 ==================";
739 execute dump_waits_account;
740 execute dump_waits_user;
741 execute dump_waits_host;
742 execute dump_waits_global;
743 execute dump_waits_history;
744 execute dump_stages_account;
745 execute dump_stages_user;
746 execute dump_stages_host;
747 execute dump_stages_global;
748 execute dump_stages_history;
749 execute dump_statements_account;
750 execute dump_statements_user;
751 execute dump_statements_host;
752 execute dump_statements_global;
753 execute dump_statements_history;
754 execute dump_accounts;
758 truncate performance_schema.events_statements_summary_by_user_by_event_name;
760 echo
"================== STATEMENTS_BY_USER truncated ==================";
762 echo
"================== Step 26 ==================";
764 execute dump_waits_account;
765 execute dump_waits_user;
766 execute dump_waits_host;
767 execute dump_waits_global;
768 execute dump_waits_history;
769 execute dump_stages_account;
770 execute dump_stages_user;
771 execute dump_stages_host;
772 execute dump_stages_global;
773 execute dump_stages_history;
774 execute dump_statements_account;
775 execute dump_statements_user;
776 execute dump_statements_host;
777 execute dump_statements_global;
778 execute dump_statements_history;
779 execute dump_accounts;
783 truncate performance_schema.events_statements_summary_by_host_by_event_name;
785 echo
"================== STATEMENTS_BY_HOST truncated ==================";
787 echo
"================== Step 27 ==================";
789 execute dump_waits_account;
790 execute dump_waits_user;
791 execute dump_waits_host;
792 execute dump_waits_global;
793 execute dump_waits_history;
794 execute dump_stages_account;
795 execute dump_stages_user;
796 execute dump_stages_host;
797 execute dump_stages_global;
798 execute dump_stages_history;
799 execute dump_statements_account;
800 execute dump_statements_user;
801 execute dump_statements_host;
802 execute dump_statements_global;
803 execute dump_statements_history;
804 execute dump_accounts;
808 truncate performance_schema.events_statements_summary_global_by_event_name;
810 echo
"================== STATEMENTS_GLOBAL truncated ==================";
812 echo
"================== Step 28 ==================";
814 execute dump_waits_account;
815 execute dump_waits_user;
816 execute dump_waits_host;
817 execute dump_waits_global;
818 execute dump_waits_history;
819 execute dump_stages_account;
820 execute dump_stages_user;
821 execute dump_stages_host;
822 execute dump_stages_global;
823 execute dump_stages_history;
824 execute dump_statements_account;
825 execute dump_statements_user;
826 execute dump_statements_host;
827 execute dump_statements_global;
828 execute dump_statements_history;
829 execute dump_accounts;
833 truncate performance_schema.accounts;
835 echo
"================== ACCOUNTS truncated ==================";
837 echo
"================== Step 29 ==================";
839 execute dump_waits_account;
840 execute dump_waits_user;
841 execute dump_waits_host;
842 execute dump_waits_global;
843 execute dump_waits_history;
844 execute dump_stages_account;
845 execute dump_stages_user;
846 execute dump_stages_host;
847 execute dump_stages_global;
848 execute dump_stages_history;
849 execute dump_statements_account;
850 execute dump_statements_user;
851 execute dump_statements_host;
852 execute dump_statements_global;
853 execute dump_statements_history;
854 execute dump_accounts;
858 truncate performance_schema.users;
860 echo
"================== USERS truncated ==================";
862 echo
"================== Step 30 ==================";
864 execute dump_waits_account;
865 execute dump_waits_user;
866 execute dump_waits_host;
867 execute dump_waits_global;
868 execute dump_waits_history;
869 execute dump_stages_account;
870 execute dump_stages_user;
871 execute dump_stages_host;
872 execute dump_stages_global;
873 execute dump_stages_history;
874 execute dump_statements_account;
875 execute dump_statements_user;
876 execute dump_statements_host;
877 execute dump_statements_global;
878 execute dump_statements_history;
879 execute dump_accounts;
883 truncate performance_schema.hosts;
885 echo
"================== HOSTS truncated ==================";
887 echo
"================== Step 31 ==================";
889 execute dump_waits_account;
890 execute dump_waits_user;
891 execute dump_waits_host;
892 execute dump_waits_global;
893 execute dump_waits_history;
894 execute dump_stages_account;
895 execute dump_stages_user;
896 execute dump_stages_host;
897 execute dump_stages_global;
898 execute dump_stages_history;
899 execute dump_statements_account;
900 execute dump_statements_user;
901 execute dump_statements_host;
902 execute dump_statements_global;
903 execute dump_statements_history;
904 execute dump_accounts;