MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
socket_summary_check.inc
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 --enable_result_log
32 
33 
34 # 1. The content of socket_summary_by_instance must be consistent to the
35 # content of socket_instances
36 #=======================================================================
37 let $part1=
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`)
43 {
44  --echo # There is an inconsistency between the content of the tables
45  --echo # socket_instances and socket_summary_by_instance
46  --echo #
47  eval
48  SELECT 'not in socket_instances' AS state, EVENT_NAME, OBJECT_INSTANCE_BEGIN
49  $part1;
50 }
51 
52 --vertical_results
53 
54 
55 # 2. The computation of statistics must be roughly correct.
56 #
57 # If we run this check sufficient frequent than AVG_TIMER_* can be removed from other checks.
58 #===============================================================================================
59 let $my_lo= 0.98;
60 let $my_hi= 1.02;
61 
62 let $my_rules=
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;
67 
68 let $part=
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;
77 
78 if(`SELECT SUM($my_rules) <> COUNT(*) FROM mysqltest.my_socket_summary_by_instance
79  WHERE pk = 'After'`)
80 {
81  --echo # The statistics looks suspicious.
82  --echo # We expect
83  --echo # $my_rules
84  eval
85  SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
86  $part
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;
91 }
92 
93 
94 # 3. Check the relation between AVG_*, MIN_TIMER_* and MAX_TIMER_*
95 #
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 #-----------------------------------------------------------------------------------------------
105 let $my_rules=
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;
110 
111 let $part=
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;
116 
117 if(`SELECT SUM($my_rules) <> COUNT(*) FROM mysqltest.my_socket_summary_by_instance
118  WHERE pk = 'After'`)
119 {
120  --echo # The statistics looks suspicious.
121  --echo # We expect
122  --echo # $my_rules
123  eval
124  SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
125  $part
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;
130 }
131 
132 
133 # 4. Check the aggregate columns COUNT_STAR and SUM_TIMER_WAIT
134 #
135 # The specification says:
136 # The columns COUNT_STAR, SUM/MIN/AVG/MAX TIMER_WAIT aggregates all operations.
137 #
138 # If we run this check sufficient frequent than COUNT_STAR and SUM_TIMER_WAIT
139 # can be removed from other checks.
140 #---------------------------------------------------------------------------------
141 let $my_rules=
142 COUNT_STAR = COUNT_READ + COUNT_WRITE + COUNT_MISC AND
143 SUM_TIMER_WAIT = SUM_TIMER_READ + SUM_TIMER_WRITE + SUM_TIMER_MISC;
144 
145 let $part=
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;
149 
150 if(`SELECT SUM($my_rules) <> COUNT(*) FROM mysqltest.my_socket_summary_by_instance
151  WHERE pk = 'After'`)
152 {
153  --echo # The statistics looks suspicious.
154  --echo # We expect
155  --echo # $my_rules
156  --echo #
157  eval
158  SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
159  $part
160  FROM mysqltest.my_socket_summary_by_instance
161  WHERE pk = 'After'
162  ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN;
163  let $print_details= 1;
164 }
165 
166 
167 # 5. Check the aggregate column MIN_TIMER_WAIT
168 #
169 # If we run this check sufficient frequent than MIN_TIMER_WAIT
170 # can be removed from other checks.
171 #---------------------------------------------------------------------------------
172 let $my_rules=
173 MIN_TIMER_WAIT >= mysqltest.min_of_triple(MIN_TIMER_READ,MIN_TIMER_WRITE,MIN_TIMER_MISC);
174 
175 let $part=
176 MIN_TIMER_WAIT,
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;
179 
180 if(`SELECT SUM($my_rules) <> COUNT(*) FROM mysqltest.my_socket_summary_by_instance
181  WHERE pk = 'After'`)
182 {
183  --echo # The statistics looks suspicious.
184  --echo # We expect
185  --echo # $my_rules
186  --echo #
187  eval
188  SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
189  $part
190  FROM mysqltest.my_socket_summary_by_instance
191  WHERE pk = 'After'
192  ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN;
193  let $print_details= 1;
194 }
195 
196 
197 # 6. Check the aggregate column MAX_TIMER_WAIT
198 #
199 # If we run this check sufficient frequent than MAX_TIMER_WAIT
200 # can be removed from other checks.
201 #---------------------------------------------------------------------------------
202 let $my_rules=
203 MAX_TIMER_WAIT >= mysqltest.max_of_triple(MAX_TIMER_READ,MAX_TIMER_WRITE,MAX_TIMER_MISC);
204 
205 let $part=
206 MAX_TIMER_WAIT,
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;
209 
210 if(`SELECT SUM($my_rules) <> COUNT(*) FROM mysqltest.my_socket_summary_by_instance
211  WHERE pk = 'After'`)
212 {
213  --echo # The statistics looks suspicious.
214  --echo # We expect
215  --echo # $my_rules
216  --echo #
217  eval
218  SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
219  $part
220  FROM mysqltest.my_socket_summary_by_instance
221  WHERE pk = 'After'
222  ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN;
223  let $print_details= 1;
224 }
225 
226 --horizontal_results
227