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