1
# Tests for PERFORMANCE_SCHEMA
2
# Verify that statistics aggregated by different criteria are consistent.
4
--source include/not_embedded.inc
5
--source include/have_perfschema.inc
6
--source include/have_QC_Disabled.inc
8
--echo "General cleanup"
11
drop table if exists t1;
14
update performance_schema.setup_instruments set enabled = 'NO';
15
update performance_schema.setup_consumers set enabled = 'NO';
18
truncate table performance_schema.file_summary_by_event_name;
19
truncate table performance_schema.file_summary_by_instance;
20
truncate table performance_schema.socket_summary_by_event_name;
21
truncate table performance_schema.socket_summary_by_instance;
22
truncate table performance_schema.events_waits_summary_global_by_event_name;
23
truncate table performance_schema.events_waits_summary_by_instance;
24
truncate table performance_schema.events_waits_summary_by_thread_by_event_name;
26
# Start recording data
27
update performance_schema.setup_consumers set enabled = 'YES';
28
update performance_schema.setup_instruments
29
set enabled = 'YES', timed = 'YES';
34
b CHAR(100) DEFAULT 'initial value')
37
insert into t1 (id) values (1), (2), (3), (4), (5), (6), (7), (8);
39
# Stop recording data, so the select below don't add noise.
40
update performance_schema.setup_instruments SET enabled = 'NO';
41
# Disable all consumers, for long standing waits
42
update performance_schema.setup_consumers set enabled = 'NO';
47
# Note that in general:
48
# - COUNT/SUM/MAX(file_summary_by_event_name) >=
49
# COUNT/SUM/MAX(file_summary_by_instance).
50
# - MIN(file_summary_by_event_name) <=
51
# MIN(file_summary_by_instance).
52
# There will be equality only when file instances are not removed,
53
# aka when a file is not deleted from the file system,
54
# because doing so removes a row in file_summary_by_instance.
57
# - COUNT/SUM/MAX(events_waits_summary_global_by_event_name) >=
58
# COUNT/SUM/MAX(events_waits_summary_by_instance)
59
# - MIN(events_waits_summary_global_by_event_name) <=
60
# MIN(events_waits_summary_by_instance)
61
# There will be equality only when an instrument instance
62
# is not removed, which is next to impossible to predictably guarantee
64
# For example, a MyISAM table removed from the table cache
65
# will cause a mysql_mutex_destroy on myisam/MYISAM_SHARE::intern_lock.
66
# Another example, a thread terminating will cause a mysql_mutex_destroy
68
# Both cause a row to be deleted from events_waits_summary_by_instance.
71
# - COUNT/SUM/MAX(events_waits_summary_global_by_event_name) >=
72
# COUNT/SUM/MAX(events_waits_summary_by_thread_by_event_name)
73
# - MIN(events_waits_summary_global_by_event_name) <=
74
# MIN(events_waits_summary_by_thread_by_event_name)
75
# There will be equality only when no thread is removed,
76
# that is if no thread disconnects, or no sub thread (for example insert
77
# delayed) ever completes.
78
# A thread completing will cause rows in
79
# events_waits_summary_by_thread_by_event_name to be removed.
81
--echo "Verifying file aggregate consistency"
83
# Since the code generating the load in this test does:
86
# - does not cause temporary tables to be used
87
# we can test for equality here for file aggregates.
89
# If any of these queries returns data, the test failed.
91
SELECT EVENT_NAME, e.COUNT_READ, SUM(i.COUNT_READ)
92
FROM performance_schema.file_summary_by_event_name AS e
93
JOIN performance_schema.file_summary_by_instance AS i USING (EVENT_NAME)
95
HAVING (e.COUNT_READ <> SUM(i.COUNT_READ))
98
SELECT EVENT_NAME, e.COUNT_WRITE, SUM(i.COUNT_WRITE)
99
FROM performance_schema.file_summary_by_event_name AS e
100
JOIN performance_schema.file_summary_by_instance AS i USING (EVENT_NAME)
102
HAVING (e.COUNT_WRITE <> SUM(i.COUNT_WRITE))
105
SELECT EVENT_NAME, e.COUNT_READ, SUM(i.COUNT_READ)
106
FROM performance_schema.socket_summary_by_event_name AS e
107
JOIN performance_schema.socket_summary_by_instance AS i USING (EVENT_NAME)
109
HAVING (e.COUNT_READ <> SUM(i.COUNT_READ))
112
SELECT EVENT_NAME, e.COUNT_WRITE, SUM(i.COUNT_WRITE)
113
FROM performance_schema.socket_summary_by_event_name AS e
114
JOIN performance_schema.socket_summary_by_instance AS i USING (EVENT_NAME)
116
HAVING (e.COUNT_WRITE <> SUM(i.COUNT_WRITE))
119
SELECT EVENT_NAME, e.SUM_NUMBER_OF_BYTES_READ, SUM(i.SUM_NUMBER_OF_BYTES_READ)
120
FROM performance_schema.file_summary_by_event_name AS e
121
JOIN performance_schema.file_summary_by_instance AS i USING (EVENT_NAME)
123
HAVING (e.SUM_NUMBER_OF_BYTES_READ <> SUM(i.SUM_NUMBER_OF_BYTES_READ))
126
SELECT EVENT_NAME, e.SUM_NUMBER_OF_BYTES_WRITE, SUM(i.SUM_NUMBER_OF_BYTES_WRITE)
127
FROM performance_schema.file_summary_by_event_name AS e
128
JOIN performance_schema.file_summary_by_instance AS i USING (EVENT_NAME)
130
HAVING (e.SUM_NUMBER_OF_BYTES_WRITE <> SUM(i.SUM_NUMBER_OF_BYTES_WRITE))
133
--echo "Verifying waits aggregate consistency (instance)"
135
SELECT EVENT_NAME, e.SUM_TIMER_WAIT, SUM(i.SUM_TIMER_WAIT)
136
FROM performance_schema.events_waits_summary_global_by_event_name AS e
137
JOIN performance_schema.events_waits_summary_by_instance AS i USING (EVENT_NAME)
139
HAVING (e.SUM_TIMER_WAIT < SUM(i.SUM_TIMER_WAIT))
142
SELECT EVENT_NAME, e.MIN_TIMER_WAIT, MIN(i.MIN_TIMER_WAIT)
143
FROM performance_schema.events_waits_summary_global_by_event_name AS e
144
JOIN performance_schema.events_waits_summary_by_instance AS i USING (EVENT_NAME)
146
HAVING (e.MIN_TIMER_WAIT > MIN(i.MIN_TIMER_WAIT))
147
AND (MIN(i.MIN_TIMER_WAIT) != 0)
150
SELECT EVENT_NAME, e.MAX_TIMER_WAIT, MAX(i.MAX_TIMER_WAIT)
151
FROM performance_schema.events_waits_summary_global_by_event_name AS e
152
JOIN performance_schema.events_waits_summary_by_instance AS i USING (EVENT_NAME)
154
HAVING (e.MAX_TIMER_WAIT < MAX(i.MAX_TIMER_WAIT))
157
--echo "Verifying waits aggregate consistency (thread)"
159
SELECT EVENT_NAME, e.SUM_TIMER_WAIT, SUM(t.SUM_TIMER_WAIT)
160
FROM performance_schema.events_waits_summary_global_by_event_name AS e
161
JOIN performance_schema.events_waits_summary_by_thread_by_event_name AS t
164
HAVING (e.SUM_TIMER_WAIT < SUM(t.SUM_TIMER_WAIT))
167
SELECT EVENT_NAME, e.MIN_TIMER_WAIT, MIN(t.MIN_TIMER_WAIT)
168
FROM performance_schema.events_waits_summary_global_by_event_name AS e
169
JOIN performance_schema.events_waits_summary_by_thread_by_event_name AS t
172
HAVING (e.MIN_TIMER_WAIT > MIN(t.MIN_TIMER_WAIT))
173
AND (MIN(t.MIN_TIMER_WAIT) != 0)
176
SELECT EVENT_NAME, e.MAX_TIMER_WAIT, MAX(t.MAX_TIMER_WAIT)
177
FROM performance_schema.events_waits_summary_global_by_event_name AS e
178
JOIN performance_schema.events_waits_summary_by_thread_by_event_name AS t
181
HAVING (e.MAX_TIMER_WAIT < MAX(t.MAX_TIMER_WAIT))
187
update performance_schema.setup_consumers set enabled = 'YES';
188
update performance_schema.setup_instruments
189
set enabled = 'YES', timed = 'YES';