Debian Codegraph @

mysql-test/suite/perfschema/include/socket_summary_check_dbg.inc

raw
1 # include/socket_summary_check.inc
2 #
3 # Auxiliary routine to be sourced by socket_summary_by_instance_func.test
4 # or other routines sourced within this script.
5 #
6 # Purpose
7 # Various checks for the content of the table socket_summary_by_instance.
8 #
9 # It is intentional that we do not try to cram as much checks as possible into
10 # one single SQL statement.
11 # Reasons:
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.
17 #
18 # IMPORTANT:
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.
25 #
26
27 --disable_query_log
28 # Insert the current state into mysqltest.my_socket_summary_by_instance.
29 eval $insert_after;
30 --enable_query_log
31
32
33 # 1. The content of socket_summary_by_instance must be consistent to the
34 # content of socket_instances
35 #-----------------------------------------------------------------------
36 let $part1=
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`)
42 {
43 --echo # There is an inconsistency between the content of the tables
44 --echo # socket_instances and socket_summary_by_instance
45 --echo #
46 eval
47 SELECT 'not in socket_instances' AS state, EVENT_NAME, OBJECT_INSTANCE_BEGIN
48 $part1;
49 --echo # abort 1
50 # exit;
51 }
52
53 --vertical_results
54
55
56 # 2. The computation of statistics must be roughly correct.
57 #
58 # If we run this check sufficient frequent than AVG_TIMER_* can be removed from other checks.
59 #-----------------------------------------------------------------------------------------------
60 let $my_lo= 0.99;
61 let $my_hi= 1.01;
62
63 let $my_rules=
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;
68
69 let $part=
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;
74
75 if(`SELECT SUM($my_rules) <> COUNT(*) FROM mysqltest.my_socket_summary_by_instance
76 WHERE pk = 'After'`)
77 {
78 --echo # The statistics looks suspicious.
79 --echo # We expect
80 --echo # $my_rules
81 eval
82 SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
83 $part
84 FROM mysqltest.my_socket_summary_by_instance
85 WHERE pk = 'After'
86 ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN;
87
88 -- echo # Debug 2a: Dump socket_summary_by_instance
89 eval
90 SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
91 $part
92 FROM performance_schema.socket_summary_by_instance
93 ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN;
94 --echo # abort 2
95 # exit;
96 }
97
98
99 # 3. Check the relation between AVG_*, MIN_TIMER_* and MAX_TIMER_*
100 #
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 #-----------------------------------------------------------------------------------------------
110 let $my_rules=
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;
115
116 let $part=
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;
121
122 if(`SELECT SUM($my_rules) <> COUNT(*) FROM mysqltest.my_socket_summary_by_instance
123 WHERE pk = 'After'`)
124 {
125 --echo # The statistics looks suspicious.
126 --echo # We expect
127 --echo # $my_rules
128 eval
129 SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
130 $part
131 FROM mysqltest.my_socket_summary_by_instance
132 WHERE pk = 'After'
133 ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN;
134 --echo # abort 3
135 # exit;
136 }
137
138
139 # 4. Check the aggregate columns COUNT_STAR and SUM_TIMER_WAIT
140 #
141 # The specification says:
142 # The columns COUNT_STAR, SUM/MIN/AVG/MAX TIMER_WAIT aggregates all operations.
143 #
144 # If we run this check sufficient frequent than COUNT_STAR and SUM_TIMER_WAIT
145 # can be removed from other checks.
146 #---------------------------------------------------------------------------------
147 let $my_rules=
148 COUNT_STAR = COUNT_READ + COUNT_WRITE + COUNT_MISC AND
149 SUM_TIMER_WAIT = SUM_TIMER_READ + SUM_TIMER_WRITE + SUM_TIMER_MISC;
150
151 let $part=
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;
155
156 if(`SELECT SUM($my_rules) <> COUNT(*) FROM mysqltest.my_socket_summary_by_instance
157 WHERE pk = 'After'`)
158 {
159 --echo # The statistics looks suspicious.
160 --echo # We expect
161 --echo # $my_rules
162 --echo #
163 eval
164 SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
165 $part
166 FROM mysqltest.my_socket_summary_by_instance
167 WHERE pk = 'After'
168 ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN;
169 --echo # abort 4
170 # exit;
171 }
172
173
174 # 5. Check the aggregate column MIN_TIMER_WAIT
175 #
176 # If we run this check sufficient frequent than MIN_TIMER_WAIT
177 # can be removed from other checks.
178 #---------------------------------------------------------------------------------
179 let $my_rules=
180 MIN_TIMER_WAIT >= mysqltest.min_of_triple(MIN_TIMER_READ,MIN_TIMER_WRITE,MIN_TIMER_MISC);
181
182 let $part=
183 MIN_TIMER_WAIT,
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;
186
187 if(`SELECT SUM($my_rules) <> COUNT(*) FROM mysqltest.my_socket_summary_by_instance
188 WHERE pk = 'After'`)
189 {
190 --echo # The statistics looks suspicious.
191 --echo # We expect
192 --echo # $my_rules
193 --echo #
194 eval
195 SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
196 $part
197 FROM mysqltest.my_socket_summary_by_instance
198 WHERE pk = 'After'
199 ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN;
200 --echo # abort 5
201 # exit;
202 }
203
204
205 # 6. Check the aggregate column MAX_TIMER_WAIT
206 #
207 # If we run this check sufficient frequent than MAX_TIMER_WAIT
208 # can be removed from other checks.
209 #---------------------------------------------------------------------------------
210 let $my_rules=
211 MAX_TIMER_WAIT >= mysqltest.max_of_triple(MAX_TIMER_READ,MAX_TIMER_WRITE,MAX_TIMER_MISC);
212
213 let $part=
214 MAX_TIMER_WAIT,
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;
217
218 if(`SELECT SUM($my_rules) <> COUNT(*) FROM mysqltest.my_socket_summary_by_instance
219 WHERE pk = 'After'`)
220 {
221 --echo # The statistics looks suspicious.
222 --echo # We expect
223 --echo # $my_rules
224 --echo #
225 eval
226 SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
227 $part
228 FROM mysqltest.my_socket_summary_by_instance
229 WHERE pk = 'After'
230 ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN;
231 --echo # abort 6
232 # exit;
233 }
234
235 --horizontal_results
236