Debian Codegraph @

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

raw
1
2 # Tests for special content of performance_schema.threads
3 #
4 # Show MySQL server related content in performance_schema.threads
5
6 --source include/not_windows.inc
7 --source include/not_embedded.inc
8 --source include/have_perfschema.inc
9
10 # Ensure that the event scheduler (started via threads_mysql-master.opt)
11 # is really running.
12 --source include/pfs_running_event_scheduler.inc
13
14 SET GLOBAL event_scheduler = OFF;
15 --source include/pfs_no_running_event_scheduler.inc
16
17 --vertical_results
18
19 # Show all "system" threads except the event scheduler
20 # ---------------------------------------------------
21 # 0. The values within the columns "thread_id" and "processlist_id" depend
22 # on server history. Therefore they are unstable and need to be omitted.
23 # 1. The columns "time" and "state" are omitted because it is thinkable that
24 # they contain slightly unstable though correct values.
25 # 2. The unification of the column "parent_thread_id" is in the moment most
26 # probably not required because I observed all time that the parent is
27 # "thread/sql/main" with the thread_id = 1.
28 # But there might be more kinds of parents with most probably unstable
29 # "thread_id" values in future.
30 # 3. In case the test is started with the option "--ps-protocol" we will
31 # find a correcet row for our current thread but the content will differ.
32 # Therefore we have to disable this protocol for the next statement.
33 --disable_ps_protocol
34 SELECT name, type, processlist_user, processlist_host, processlist_db,
35 processlist_command, processlist_info, connection_type,
36 IF(parent_thread_id IS NULL, parent_thread_id, 'unified parent_thread_id')
37 AS unified_parent_thread_id,
38 `role`, instrumented
39 FROM performance_schema.threads
40 WHERE name LIKE 'thread/sql%'
41 AND (name != 'thread/sql/one_connection' OR processlist_id=connection_id())
42 ORDER BY name;
43 --enable_ps_protocol
44
45 CREATE TEMPORARY TABLE t1 AS
46 SELECT thread_id FROM performance_schema.threads
47 WHERE name LIKE 'thread/sql%';
48
49
50 SET GLOBAL event_scheduler = ON;
51 --source include/pfs_running_event_scheduler.inc
52
53 # Show entries belonging to the just started event scheduler
54 SELECT name, type, processlist_user, processlist_host, processlist_db,
55 processlist_command, processlist_info,
56 IF(parent_thread_id IS NULL, parent_thread_id, 'unified parent_thread_id')
57 AS unified_parent_thread_id,
58 `role`, instrumented
59 FROM performance_schema.threads
60 WHERE name LIKE 'thread/sql%'
61 AND thread_id NOT IN (SELECT thread_id FROM t1)
62 ORDER BY name;
63
64 TRUNCATE t1;
65 INSERT INTO t1
66 SELECT thread_id FROM performance_schema.threads
67 WHERE name LIKE 'thread/sql%';
68 --disable_cursor_protocol
69 SELECT COUNT(*) INTO @aux FROM t1;
70 --enable_cursor_protocol
71
72 # Attention:
73 # Just waiting for some new thread showing up is not sufficient because
74 # because the successing SELECT showing the thread might catch this thread
75 # in a very early and short phase.
76 # process_info si quite often
77 # CREATE PROCEDURE `t_ps_event`() SQL SECURITY INVOKER SELECT SLEEP(3)
78 #
79 let $wait_condition=
80 SELECT COUNT(*) = 1 FROM information_schema.processlist
81 WHERE info = 'SELECT SLEEP(3)';
82
83 --disable_warnings
84 DROP EVENT IF EXISTS t_ps_event;
85 --enable_warnings
86 CREATE EVENT t_ps_event
87 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND
88 DO SELECT SLEEP(3);
89
90 # Wait till one more thread comes up.
91 # This must be the event worker thread.
92 let $wait_timeout= 20;
93 --source include/wait_condition.inc
94
95 # Show entries belonging to the just started event worker
96 SELECT name, type, processlist_user, processlist_host, processlist_db,
97 processlist_command, processlist_info,
98 IF(parent_thread_id IS NULL, parent_thread_id, 'unified parent_thread_id')
99 AS unified_parent_thread_id,
100 `role`, instrumented
101 FROM performance_schema.threads
102 WHERE name LIKE 'thread/sql%'
103 AND thread_id NOT IN (SELECT thread_id FROM t1)
104 ORDER BY name;
105
106 # Show parent - child relations between "system" threads
107 # ------------------------------------------------------
108 --horizontal_results
109 SELECT t2.name AS parent_thread_name, t1.name AS child_thread_name
110 FROM performance_schema.threads t1 INNER JOIN performance_schema.threads t2
111 ON t1.parent_thread_id = t2.thread_id
112 WHERE t1.name LIKE 'thread/sql%'
113 AND t1.parent_thread_id IS NOT NULL
114 AND (t1.name != 'thread/sql/one_connection' OR t1.processlist_id=connection_id())
115 ORDER BY parent_thread_name, child_thread_name;
116
117 # Cleanup
118 # Wait till the event worker disappeared
119 --source include/no_running_events.inc
120