1 # include/socket_summary_check.inc
3 # Auxiliary routine to be sourced by socket_summary_by_instance_func.test
4 # or other routines sourced within this script.
7 # Various checks for the content of the table socket_summary_by_instance.
9 # It is intentional that we do not try to cram as much checks as possible into
10 # one single SQL statement.
12 # - We check performance_schema here and NOT something like optimizer.
13 # - This test should work even if some other feature has become buggy.
14 # - In case some check gives unexpected results than we print the
15 # relevant content of the table and the values which we expect.
16 # In case of all checks in one statement such a printout would be too huge.
19 # The maximum number of rows which the table socket_summary_by_instance
20 # can keep is limited via the system variables max_socket_classes and
21 # max_socket_instances. We are running with the default values here.
22 # They are sufficient high so that these limits cannot harm the current test.
23 # FIXME: Check at the beginning of the test that the limits are sufficient
24 # for the current test.
28 # Insert the current state into mysqltest.my_socket_summary_by_instance.
33 # 1. The content of socket_summary_by_instance must be consistent to the
34 # content of socket_instances
35 #-----------------------------------------------------------------------
37 FROM performance_schema.socket_summary_by_instance
38 WHERE (EVENT_NAME,OBJECT_INSTANCE_BEGIN)
39 NOT IN (SELECT EVENT_NAME,OBJECT_INSTANCE_BEGIN
40 FROM performance_schema.socket_instances);
41 if(`SELECT COUNT(*) $part1`)
43 --echo # There is an inconsistency between the content of the tables
44 --echo # socket_instances and socket_summary_by_instance
47 SELECT
'not in socket_instances' AS state, EVENT_NAME, OBJECT_INSTANCE_BEGIN
56 # 2. The computation of statistics must be roughly correct.
58 # If we run this check sufficient frequent than AVG_TIMER_* can be removed from other checks.
59 #-----------------------------------------------------------------------------------------------
64 COUNT_STAR * AVG_TIMER_WAIT BETWEEN SUM_TIMER_WAIT * $my_lo AND SUM_TIMER_WAIT * $my_hi AND
65 COUNT_READ * AVG_TIMER_READ BETWEEN SUM_TIMER_READ * $my_lo AND SUM_TIMER_READ * $my_hi AND
66 COUNT_WRITE * AVG_TIMER_WRITE BETWEEN SUM_TIMER_WRITE * $my_lo AND SUM_TIMER_WRITE * $my_hi AND
67 COUNT_MISC * AVG_TIMER_MISC BETWEEN SUM_TIMER_MISC * $my_lo AND SUM_TIMER_MISC * $my_hi;
70 SUM_TIMER_WAIT * $my_lo, COUNT_STAR * AVG_TIMER_WAIT, SUM_TIMER_WAIT * $my_hi, COUNT_STAR, SUM_TIMER_WAIT, AVG_TIMER_WAIT,
71 SUM_TIMER_READ * $my_lo, COUNT_READ * AVG_TIMER_READ, SUM_TIMER_READ * $my_hi, COUNT_READ, SUM_TIMER_READ, AVG_TIMER_READ,
72 SUM_TIMER_WRITE * $my_lo, COUNT_WRITE * AVG_TIMER_WRITE, SUM_TIMER_WRITE * $my_hi, COUNT_WRITE, SUM_TIMER_WRITE, AVG_TIMER_WRITE,
73 SUM_TIMER_MISC * $my_lo, COUNT_MISC * AVG_TIMER_MISC, SUM_TIMER_MISC * $my_hi, COUNT_MISC, SUM_TIMER_MISC, AVG_TIMER_MISC;
75 if(`SELECT SUM($my_rules) <> COUNT(*) FROM mysqltest.my_socket_summary_by_instance
78 --echo # The statistics looks suspicious.
82 SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
84 FROM mysqltest.my_socket_summary_by_instance
86 ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN;
88 -- echo # Debug 2a: Dump socket_summary_by_instance
90 SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
92 FROM performance_schema.socket_summary_by_instance
93 ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN;
99 # 3. Check the relation between AVG_*, MIN_TIMER_* and MAX_TIMER_*
101 # If we run this check sufficient frequent than only the following
102 # additional checks are required:
103 # a) If (SUM_TIMER_*(new) - SUM_TIMER_*(old) < MIN_TIMER_*(old))
104 # than MIN_TIMER_*(new) = SUM_TIMER_*(new) - SUM_TIMER_*(old).
105 # b) If (SUM_TIMER_*(new) - SUM_TIMER_*(old) > MAX_TIMER_*(old))
106 # than MAX_TIMER_*(new) = SUM_TIMER_*(new) - SUM_TIMER_*(old).
107 # in order to remove MIN_TIMER_* and MAX_TIMER_* from other checks
108 # Between the states "new" and "old" must be exact one statement.
109 #-----------------------------------------------------------------------------------------------
111 AVG_TIMER_WAIT >= MIN_TIMER_WAIT AND MAX_TIMER_WAIT >= AVG_TIMER_WAIT AND
112 AVG_TIMER_READ >= MIN_TIMER_READ AND MAX_TIMER_READ >= AVG_TIMER_READ AND
113 AVG_TIMER_WRITE >= MIN_TIMER_WRITE AND MAX_TIMER_WRITE >= AVG_TIMER_WRITE AND
114 AVG_TIMER_MISC >= MIN_TIMER_MISC AND MAX_TIMER_MISC >= AVG_TIMER_MISC;
117 MIN_TIMER_WAIT, AVG_TIMER_WAIT, MAX_TIMER_WAIT,
118 MIN_TIMER_READ, AVG_TIMER_READ, MAX_TIMER_READ,
119 MIN_TIMER_WRITE, AVG_TIMER_WRITE, MAX_TIMER_WRITE,
120 MIN_TIMER_MISC, AVG_TIMER_MISC, MAX_TIMER_MISC;
122 if(`SELECT SUM($my_rules) <> COUNT(*) FROM mysqltest.my_socket_summary_by_instance
125 --echo # The statistics looks suspicious.
129 SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
131 FROM mysqltest.my_socket_summary_by_instance
133 ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN;
139 # 4. Check the aggregate columns COUNT_STAR and SUM_TIMER_WAIT
141 # The specification says:
142 # The columns COUNT_STAR, SUM/MIN/AVG/MAX TIMER_WAIT aggregates all operations.
144 # If we run this check sufficient frequent than COUNT_STAR and SUM_TIMER_WAIT
145 # can be removed from other checks.
146 #---------------------------------------------------------------------------------
148 COUNT_STAR = COUNT_READ + COUNT_WRITE + COUNT_MISC AND
149 SUM_TIMER_WAIT = SUM_TIMER_READ + SUM_TIMER_WRITE + SUM_TIMER_MISC;
152 COUNT_STAR, COUNT_READ + COUNT_WRITE + COUNT_MISC, COUNT_READ, COUNT_WRITE, COUNT_MISC,
153 SUM_TIMER_WAIT, SUM_TIMER_READ + SUM_TIMER_WRITE + SUM_TIMER_MISC, SUM_TIMER_READ,
154 SUM_TIMER_WRITE, SUM_TIMER_MISC;
156 if(`SELECT SUM($my_rules) <> COUNT(*) FROM mysqltest.my_socket_summary_by_instance
159 --echo # The statistics looks suspicious.
164 SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
166 FROM mysqltest.my_socket_summary_by_instance
168 ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN;
174 # 5. Check the aggregate column MIN_TIMER_WAIT
176 # If we run this check sufficient frequent than MIN_TIMER_WAIT
177 # can be removed from other checks.
178 #---------------------------------------------------------------------------------
180 MIN_TIMER_WAIT >= mysqltest.min_of_triple(MIN_TIMER_READ,MIN_TIMER_WRITE,MIN_TIMER_MISC);
184 mysqltest.min_of_triple(MIN_TIMER_READ, MIN_TIMER_WRITE, MIN_TIMER_MISC) AS
"Min_of_Triple",
185 MIN_TIMER_READ, MIN_TIMER_WRITE, MIN_TIMER_MISC;
187 if(`SELECT SUM($my_rules) <> COUNT(*) FROM mysqltest.my_socket_summary_by_instance
190 --echo # The statistics looks suspicious.
195 SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
197 FROM mysqltest.my_socket_summary_by_instance
199 ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN;
205 # 6. Check the aggregate column MAX_TIMER_WAIT
207 # If we run this check sufficient frequent than MAX_TIMER_WAIT
208 # can be removed from other checks.
209 #---------------------------------------------------------------------------------
211 MAX_TIMER_WAIT >= mysqltest.max_of_triple(MAX_TIMER_READ,MAX_TIMER_WRITE,MAX_TIMER_MISC);
215 mysqltest.max_of_triple(MAX_TIMER_READ, MAX_TIMER_WRITE, MAX_TIMER_MISC) AS
"Max_of_Triple",
216 MAX_TIMER_READ, MAX_TIMER_WRITE, MAX_TIMER_MISC;
218 if(`SELECT SUM($my_rules) <> COUNT(*) FROM mysqltest.my_socket_summary_by_instance
221 --echo # The statistics looks suspicious.
226 SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
228 FROM mysqltest.my_socket_summary_by_instance
230 ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN;