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.
34 # 1. The content of socket_summary_by_instance must be consistent to the
35 # content of socket_instances
36 #=======================================================================
38 FROM performance_schema.socket_summary_by_instance
39 WHERE (EVENT_NAME,OBJECT_INSTANCE_BEGIN)
40 NOT IN (SELECT EVENT_NAME,OBJECT_INSTANCE_BEGIN
41 FROM performance_schema.socket_instances);
42 if(`SELECT COUNT(*) $part1`)
44 --echo # There is an inconsistency between the content of the tables
45 --echo # socket_instances and socket_summary_by_instance
48 SELECT
'not in socket_instances' AS state, EVENT_NAME, OBJECT_INSTANCE_BEGIN
55 # 2. The computation of statistics must be roughly correct.
57 # If we run this check sufficient frequent than AVG_TIMER_* can be removed from other checks.
58 #===============================================================================================
63 COUNT_STAR * AVG_TIMER_WAIT BETWEEN SUM_TIMER_WAIT * $my_lo AND SUM_TIMER_WAIT * $my_hi AND
64 COUNT_READ * AVG_TIMER_READ BETWEEN SUM_TIMER_READ * $my_lo AND SUM_TIMER_READ * $my_hi AND
65 COUNT_WRITE * AVG_TIMER_WRITE BETWEEN SUM_TIMER_WRITE * $my_lo AND SUM_TIMER_WRITE * $my_hi AND
66 COUNT_MISC * AVG_TIMER_MISC BETWEEN SUM_TIMER_MISC * $my_lo AND SUM_TIMER_MISC * $my_hi;
69 SUM_TIMER_WAIT * $my_lo, COUNT_STAR * AVG_TIMER_WAIT, SUM_TIMER_WAIT * $my_hi,
70 COUNT_STAR, SUM_TIMER_WAIT, AVG_TIMER_WAIT,
71 SUM_TIMER_READ * $my_lo, COUNT_READ * AVG_TIMER_READ, SUM_TIMER_READ * $my_hi,
72 COUNT_READ, SUM_TIMER_READ, AVG_TIMER_READ,
73 SUM_TIMER_WRITE * $my_lo, COUNT_WRITE * AVG_TIMER_WRITE, SUM_TIMER_WRITE * $my_hi,
74 COUNT_WRITE, SUM_TIMER_WRITE, AVG_TIMER_WRITE,
75 SUM_TIMER_MISC * $my_lo, COUNT_MISC * AVG_TIMER_MISC, SUM_TIMER_MISC * $my_hi,
76 COUNT_MISC, SUM_TIMER_MISC, AVG_TIMER_MISC;
78 if(`SELECT SUM($my_rules) <> COUNT(*) FROM mysqltest.my_socket_summary_by_instance
81 --echo # The statistics looks suspicious.
85 SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
87 FROM mysqltest.my_socket_summary_by_instance
88 WHERE pk =
'After' AND NOT ($my_rules)
89 ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN;
90 let $print_details= 1;
94 # 3. Check the relation between AVG_*, MIN_TIMER_* and MAX_TIMER_*
96 # If we run this check sufficient frequent than only the following
97 # additional checks are required:
98 # a) If (SUM_TIMER_*(new) - SUM_TIMER_*(old) < MIN_TIMER_*(old))
99 # than MIN_TIMER_*(new) = SUM_TIMER_*(new) - SUM_TIMER_*(old).
100 # b) If (SUM_TIMER_*(new) - SUM_TIMER_*(old) > MAX_TIMER_*(old))
101 # than MAX_TIMER_*(new) = SUM_TIMER_*(new) - SUM_TIMER_*(old).
102 # in order to remove MIN_TIMER_* and MAX_TIMER_* from other checks
103 # Between the states "new" and "old" must be exact one statement.
104 #-----------------------------------------------------------------------------------------------
106 AVG_TIMER_WAIT >= MIN_TIMER_WAIT AND MAX_TIMER_WAIT >= AVG_TIMER_WAIT AND
107 AVG_TIMER_READ >= MIN_TIMER_READ AND MAX_TIMER_READ >= AVG_TIMER_READ AND
108 AVG_TIMER_WRITE >= MIN_TIMER_WRITE AND MAX_TIMER_WRITE >= AVG_TIMER_WRITE AND
109 AVG_TIMER_MISC >= MIN_TIMER_MISC AND MAX_TIMER_MISC >= AVG_TIMER_MISC;
112 MIN_TIMER_WAIT, AVG_TIMER_WAIT, MAX_TIMER_WAIT,
113 MIN_TIMER_READ, AVG_TIMER_READ, MAX_TIMER_READ,
114 MIN_TIMER_WRITE, AVG_TIMER_WRITE, MAX_TIMER_WRITE,
115 MIN_TIMER_MISC, AVG_TIMER_MISC, MAX_TIMER_MISC;
117 if(`SELECT SUM($my_rules) <> COUNT(*) FROM mysqltest.my_socket_summary_by_instance
120 --echo # The statistics looks suspicious.
124 SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
126 FROM mysqltest.my_socket_summary_by_instance
127 WHERE pk =
'After' AND NOT ($my_rules)
128 ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN;
129 let $print_details= 1;
133 # 4. Check the aggregate columns COUNT_STAR and SUM_TIMER_WAIT
135 # The specification says:
136 # The columns COUNT_STAR, SUM/MIN/AVG/MAX TIMER_WAIT aggregates all operations.
138 # If we run this check sufficient frequent than COUNT_STAR and SUM_TIMER_WAIT
139 # can be removed from other checks.
140 #---------------------------------------------------------------------------------
142 COUNT_STAR = COUNT_READ + COUNT_WRITE + COUNT_MISC AND
143 SUM_TIMER_WAIT = SUM_TIMER_READ + SUM_TIMER_WRITE + SUM_TIMER_MISC;
146 COUNT_STAR, COUNT_READ + COUNT_WRITE + COUNT_MISC, COUNT_READ, COUNT_WRITE, COUNT_MISC,
147 SUM_TIMER_WAIT, SUM_TIMER_READ + SUM_TIMER_WRITE + SUM_TIMER_MISC, SUM_TIMER_READ,
148 SUM_TIMER_WRITE, SUM_TIMER_MISC;
150 if(`SELECT SUM($my_rules) <> COUNT(*) FROM mysqltest.my_socket_summary_by_instance
153 --echo # The statistics looks suspicious.
158 SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
160 FROM mysqltest.my_socket_summary_by_instance
162 ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN;
163 let $print_details= 1;
167 # 5. Check the aggregate column MIN_TIMER_WAIT
169 # If we run this check sufficient frequent than MIN_TIMER_WAIT
170 # can be removed from other checks.
171 #---------------------------------------------------------------------------------
173 MIN_TIMER_WAIT >= mysqltest.min_of_triple(MIN_TIMER_READ,MIN_TIMER_WRITE,MIN_TIMER_MISC);
177 mysqltest.min_of_triple(MIN_TIMER_READ, MIN_TIMER_WRITE, MIN_TIMER_MISC) AS
"Min_of_Triple",
178 MIN_TIMER_READ, MIN_TIMER_WRITE, MIN_TIMER_MISC;
180 if(`SELECT SUM($my_rules) <> COUNT(*) FROM mysqltest.my_socket_summary_by_instance
183 --echo # The statistics looks suspicious.
188 SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
190 FROM mysqltest.my_socket_summary_by_instance
192 ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN;
193 let $print_details= 1;
197 # 6. Check the aggregate column MAX_TIMER_WAIT
199 # If we run this check sufficient frequent than MAX_TIMER_WAIT
200 # can be removed from other checks.
201 #---------------------------------------------------------------------------------
203 MAX_TIMER_WAIT >= mysqltest.max_of_triple(MAX_TIMER_READ,MAX_TIMER_WRITE,MAX_TIMER_MISC);
207 mysqltest.max_of_triple(MAX_TIMER_READ, MAX_TIMER_WRITE, MAX_TIMER_MISC) AS
"Max_of_Triple",
208 MAX_TIMER_READ, MAX_TIMER_WRITE, MAX_TIMER_MISC;
210 if(`SELECT SUM($my_rules) <> COUNT(*) FROM mysqltest.my_socket_summary_by_instance
213 --echo # The statistics looks suspicious.
218 SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
220 FROM mysqltest.my_socket_summary_by_instance
222 ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN;
223 let $print_details= 1;