Debian Codegraph @

mysql-test/suite/perfschema/r/error_log.result

raw
1 # WL#13681: Make error-log available for queries from a connection
2
3 SET @@global.log_error_verbosity=3;
4
5 # FR-1.1 Table name
6 # FR-1.2 Columns and names
7 DESC performance_schema.error_log;
8 Field Type Null Key Default Extra
9 LOGGED timestamp(6) NO PRI NULL
10 THREAD_ID bigint unsigned YES MUL NULL
11 PRIO enum('System','Error','Warning','Note') NO MUL NULL
12 ERROR_CODE varchar(10) YES MUL NULL
13 SUBSYSTEM varchar(7) YES MUL NULL
14 DATA text NO NULL
15 #
16 # PART I - Traditional error log
17 #
18
19 SET @@session.time_zone=@@global.log_timestamps;
20
21 # We have 4 new status variables to monitor the ring-buffer:
22 SELECT VARIABLE_NAME
23 FROM performance_schema.global_status
24 WHERE VARIABLE_NAME LIKE "Error_log_%";
25 VARIABLE_NAME
26 Error_log_buffered_bytes
27 Error_log_buffered_events
28 Error_log_expired_events
29 Error_log_latest_write
30
31 # Show that we're logging to stderr:
32 SELECT @@global.log_error;
33 @@global.log_error
34 stderr
35
36 # Determine start-up time. Must succeed for other results to have meaning.
37 SELECT logged INTO @startup
38 FROM performance_schema.error_log
39 WHERE error_code="MY-010116" ORDER BY logged DESC LIMIT 1;
40
41 # Since we're logging to stderr, we should see this message exactly once
42 # (from our current start-up). Otherwise, we might see more of them from
43 # previous runs:
44 SELECT COUNT(logged)
45 FROM performance_schema.error_log
46 WHERE error_code="MY-010116" ORDER BY logged;
47 COUNT(logged)
48 1
49
50 # number of buffered events should agree between status and COUNT(*)
51 SELECT COUNT(*) INTO @count_select
52 FROM performance_schema.error_log
53 WHERE logged>=@startup
54 ORDER BY logged;
55 SELECT VARIABLE_VALUE INTO @count_status
56 FROM performance_schema.global_status
57 WHERE VARIABLE_NAME LIKE "Error_log_buffered_events";
58 #
59 # SELECT with = cond on indexed field
60 SELECT prio,error_code,subsystem,data
61 FROM performance_schema.error_log
62 WHERE data="InnoDB initialization has ended.";
63 prio error_code subsystem data
64 System MY-013577 InnoDB InnoDB initialization has ended.
65
66 # FR-1.3.2 Trad log mode
67 # Show the log. No messages here because of non-deterministic parts.
68 # We're also filtering out a number of messages that behave differently
69 # on the first run vis-a-vis subsequent runs with --repeat=..., and some
70 # that we don't know the sequence of because of multi-threading, or that
71 # may or may not appear depending on the machine the test is run on.
72 #
73 # We're filtering this here explicitly to make it more obvious what is
74 # happening. In a real world scenario, this kind of filtering is unlikely
75 # to be desired, and where it is, using --log-error-suppression-list=...
76 # should address the issue. Alternatively, a table of exclusions or a
77 # user-variable and dynamic SQL could be used to streamline the statement
78 # and de-duplicate the exclusion list. For testing in other .tests (i.e.
79 # where we're testing things other than the pfs.error_log mechanism
80 # itself), any of those options could be pre-populated with a sensible
81 # default list of exclusions by mysql-test-run.
82 SELECT prio,error_code,subsystem
83 FROM performance_schema.error_log
84 WHERE logged>=@startup
85 AND error_code NOT IN("MY-011243", "MY-011240", "MY-011245", "MY-010931",
86 "MY-010949", "MY-010747", "MY-013546", "MY-010051",
87 "MY-011946", "MY-012922", "MY-011810", "MY-012932",
88 "MY-011952", "MY-011323", "MY-010902", "MY-000000",
89 "MY-012937", "MY-012366", "MY-000067", "MY-010159",
90 "MY-013602", "MY-010069", "MY-013595", "MY-010108",
91 "MY-012363", "MY-011953", "MY-013623", "MY-013711",
92 "MY-013880", "MY-013881", "MY-013882", "MY-013883",
93 "MY-013884", "MY-013908", "MY-013930")
94 ORDER BY logged, error_code;
95 prio error_code subsystem
96 System MY-010116 Server
97 Warning MY-010075 Server
98 System MY-013576 InnoDB
99 Note MY-012944 InnoDB
100 Note MY-012945 InnoDB
101 Note MY-012948 InnoDB
102 Note MY-012951 InnoDB
103 Note MY-012203 InnoDB
104 Note MY-012204 InnoDB
105 Note MY-012208 InnoDB
106 Note MY-012955 InnoDB
107 Note MY-012957 InnoDB
108 Note MY-013532 InnoDB
109 Note MY-013532 InnoDB
110 Note MY-013566 InnoDB
111 Note MY-013565 InnoDB
112 Note MY-013532 InnoDB
113 Note MY-013532 InnoDB
114 Note MY-013086 InnoDB
115 Note MY-013083 InnoDB
116 Note MY-012532 InnoDB
117 Note MY-012535 InnoDB
118 Note MY-013252 InnoDB
119 Note MY-013252 InnoDB
120 Note MY-012910 InnoDB
121 Note MY-011980 InnoDB
122 Note MY-013776 InnoDB
123 Note MY-013777 InnoDB
124 Note MY-012923 InnoDB
125 Note MY-012265 InnoDB
126 Note MY-012266 InnoDB
127 Note MY-013627 InnoDB
128 Note MY-013018 InnoDB
129 Note MY-012976 InnoDB
130 System MY-013577 InnoDB
131 Note MY-011089 Server
132 Note MY-012357 InnoDB
133 Note MY-012356 InnoDB
134 Note MY-010006 Server
135 Note MY-011332 Server
136 Note MY-013911 Server
137 Note MY-013911 Server
138 Note MY-012487 InnoDB
139 Note MY-012488 InnoDB
140 Note MY-010303 Server
141 Warning MY-010068 Server
142 Note MY-010310 Server
143 Note MY-010310 Server
144 Note MY-010252 Server
145 Note MY-010253 Server
146 Note MY-010264 Server
147 Note MY-010251 Server
148 Note MY-011025 Repl
149
150 # Don't show NOTEs:
151 SELECT prio,error_code,subsystem,data
152 FROM performance_schema.error_log
153 WHERE logged>=@startup
154 AND prio!="Note"
155 AND error_code NOT IN("MY-011323", "MY-010075", "MY-010068", "MY-010069",
156 "MY-010931", "MY-010116", "MY-011810", "MY-000000",
157 "MY-000067", "MY-010159", "MY-013595", "MY-013602",
158 "MY-010108", "MY-012363", "MY-013711", "MY-013908",
159 "MY-013930" )
160 ORDER BY logged;
161 prio error_code subsystem data
162 System MY-013576 InnoDB InnoDB initialization has started.
163 System MY-013577 InnoDB InnoDB initialization has ended.
164
165 # FR-1.4.1 Show the log-error-verbosity applies
166 # We passed --log-error-verbosity=3 at start-up. Show that we have Notes.
167 SELECT COUNT(*)>0
168 FROM performance_schema.error_log
169 WHERE logged>=@startup
170 AND prio NOT IN("System", "Warning", "Error");
171 COUNT(*)>0
172 1
173
174 ########################################################################
175 # Restart with a broken trad log ...
176
177 # restart: --log-error=LOG_FILE_TRAD --log-error-verbosity=3
178 SET @@session.time_zone=@@global.log_timestamps;
179 SELECT logged INTO @startup
180 FROM performance_schema.error_log
181 WHERE error_code="MY-010116" ORDER BY logged DESC LIMIT 1;
182 SELECT LEFT(logged,19), error_code, subsystem, data
183 FROM performance_schema.error_log
184 WHERE logged<@startup AND error_code="MY-999999";
185 LEFT(logged,19) error_code subsystem data
186 2000-01-01 00:00:00 MY-999999 Server Fake start
187 2000-01-01 00:00:02 MY-999999 Server No message found for this event while parsing a traditional error log! If you wish to investigate this, use this event's timestamp to find the offending line in the error log file.
188 2000-01-01 00:00:03 MY-999999 Server Fake end
189
190 ########################################################################
191 # Restart with JSON logging ...
192
193 # restart: --log-error-services=log_filter_internal;log_sink_json --log-error=LOG_FILE_JSON --log-error-verbosity=3
194 #
195 # PART II - JSON error log
196 #
197
198 SET @@session.time_zone=@@global.log_timestamps;
199
200 # Determine start-up time. Must succeed for other results to have meaning
201 SELECT logged INTO @startup
202 FROM performance_schema.error_log
203 WHERE error_code="MY-010116" ORDER BY logged DESC LIMIT 1;
204
205 # FR-1.3.3 JSON log mode
206 # SELECT with = cond with (possibly) several results
207 SELECT logged=@startup
208 FROM performance_schema.error_log
209 WHERE error_code="MY-010116" ORDER BY logged DESC LIMIT 1;
210 logged=@startup
211 1
212
213 # Extract a key/value pair from a JSON record:
214 SELECT prio,error_code,subsystem,JSON_EXTRACT(data,'$.err_symbol')
215 FROM performance_schema.error_log
216 WHERE logged>=@startup
217 AND LEFT(data,1)='{'
218 AND JSON_EXTRACT(data,'$.err_symbol')="ER_STARTING_AS"
219 ORDER BY logged;
220 prio error_code subsystem JSON_EXTRACT(data,'$.err_symbol')
221 System MY-010116 Server "ER_STARTING_AS"
222
223 # FR-1.4.2 Information from previous run/log
224 # FR-2 Loading information from previous run
225 # FR-2.2.3 Restoring from the JSON log
226 # Pre-existing record appears BEFORE our start-up marker.
227 # Note also the timestamps:
228 # - The timestamp in the JSON record preserves the original timestamp.
229 # - The timestamp in the logged column is strictly increasing.
230 SELECT logged, prio, error_code, subsystem, data
231 FROM performance_schema.error_log
232 WHERE logged<@startup
233 AND JSON_EXTRACT(data,'$.Azundris')="was here"
234 ORDER BY logged;
235 logged prio error_code subsystem data
236 1979-02-24 00:00:00.000000 System MY-010000 Server { "prio" : 0, "err_symbol" : "ER_PARSER_TRACE", "msg" : "Testing WL#13681 ... 1/4", "time" : "1979-02-24T00:00:00.000000Z", "ts" : 0, "thread" : 0, "SQL_state" : "XX999", "subsystem" : "Server", "label" : "System", "Azundris" : "was here" }
237 1979-02-24 00:00:00.000001 System MY-010000 Server { "prio" : 0, "err_symbol" : "ER_PARSER_TRACE", "msg" : "Testing WL#13681 ... 2/4", "time" : "1979-02-23T00:00:00.000000Z", "ts" : 0, "thread" : 0, "SQL_state" : "XX999", "subsystem" : "Server", "label" : "System", "Azundris" : "was here" }
238
239 # - The "zero" timestamp in the input is replaced with present date/time.
240 SELECT logged>"2020-02-24 12:34:56.123456", prio, error_code, subsystem, data
241 FROM performance_schema.error_log
242 WHERE logged<@startup
243 AND JSON_EXTRACT(data,'$.Azundris')="auto-generate timestamp"
244 ORDER BY logged;
245 logged>"2020-02-24 12:34:56.123456" prio error_code subsystem data
246 1 System MY-010000 Server { "prio" : 0, "err_symbol" : "ER_PARSER_TRACE", "msg" : "Testing WL#13681 ... 3/4", "time" : "1970-01-01T00:00:00.000000Z", "ts" : 0, "thread" : 0, "SQL_state" : "XX999", "subsystem" : "Server", "label" : "System", "Azundris" : "auto-generate timestamp" }
247
248 # Cleanup.
249 SET GLOBAL log_error_services= DEFAULT;
250 DELETE FROM mysql.component
251 WHERE component_urn="file://component_log_sink_json";
252 #
253 # Various tests to help QA WL#13681 - performance_schema.error_log
254 #
255
256
257 # First, restart with various --log-error-verbosity=...,
258 # but not --log-error=... (so when running from mtr,
259 # errors will be logged to stderr).
260
261
262 # Restarting server with --log-error-verbosity=1
263 # restart: --log-error-verbosity=1
264 SELECT logged INTO @startup
265 FROM performance_schema.error_log
266 WHERE error_code="MY-010116"
267 ORDER BY logged DESC LIMIT 1;
268
269 # There should be no warnings/infos with verbosity=1.
270 SELECT COUNT(*)=0
271 FROM performance_schema.error_log
272 WHERE logged>=@startup AND prio NOT IN("Error","System");
273 COUNT(*)=0
274 1
275
276 # Restarting server with --log-error-verbosity=2
277 # restart: --log-error-verbosity=2
278 SELECT logged INTO @startup
279 FROM performance_schema.error_log
280 WHERE error_code="MY-010116"
281 ORDER BY logged DESC LIMIT 1;
282
283 # There should be no infos with verbosity=2.
284 SELECT COUNT(*)=0
285 FROM performance_schema.error_log
286 WHERE logged>=@startup AND prio NOT IN("Warning", "Error", "System");
287 COUNT(*)=0
288 1
289
290 # Now restart with various --log-error-verbosity=...,
291 # and --log-error=... (so when running from mtr,
292 # errors will be logged to a file, and if a suitable
293 # log-sink is used, previous logs can be read).
294
295
296 # verbosity=1
297 # restart: --log-error=LOG_FILE_V1 --log-error-verbosity=1
298 SELECT logged INTO @startup
299 FROM performance_schema.error_log
300 WHERE error_code="MY-010116"
301 ORDER BY logged DESC LIMIT 1;
302
303 # There should be no warnings/infos with verbosity=1.
304 SELECT COUNT(*)=0
305 FROM performance_schema.error_log
306 WHERE logged>=@startup AND prio NOT IN("Error", "System");
307 COUNT(*)=0
308 1
309
310 # verbosity=2
311 # restart: --log-error=LOG_FILE_V2 --log-error-verbosity=2
312 SELECT logged INTO @startup
313 FROM performance_schema.error_log
314 WHERE error_code="MY-010116"
315 ORDER BY logged DESC LIMIT 1;
316
317 # There should be warnings/infos with verbosity=2.
318 SELECT COUNT(*)>0
319 FROM performance_schema.error_log
320 WHERE logged>=@startup AND prio NOT IN("Error", "System");
321 COUNT(*)>0
322 1
323
324 # verbosity=3
325 # restart: --log-error=LOG_FILE_V3 --log-error-verbosity=3
326 SELECT logged INTO @startup
327 FROM performance_schema.error_log
328 WHERE error_code="MY-010116"
329 ORDER BY logged DESC LIMIT 1;
330
331 # There should be infos with verbosity=3.
332 SELECT COUNT(*)>0
333 FROM performance_schema.error_log
334 WHERE logged>=@startup AND prio NOT IN("Note");
335 COUNT(*)>0
336 1
337
338 # Pass --log-error-suppression-list at start-up, then show that the
339 # listed errors have been excluded from the table!
340 # restart: --log-error-suppression-list=MY-013595,MY-010069,MY-011810,MY-010116 --log-error-verbosity=3
341 # Show that log_error_suppression_list was accepted from the command-line.
342 SELECT @@global.log_error_suppression_list;
343 @@global.log_error_suppression_list
344 MY-013595,MY-010069,MY-011810,MY-010116
345 # Show that we have no log file (i.e. we're logging to stderr).
346 # This is to guard against --log-error=... being added to the .opt file,
347 # which would then be applied on every restart and skew results in subtle ways.
348 SELECT @@global.log_error;
349 @@global.log_error
350 stderr
351 SELECT error_code
352 FROM performance_schema.error_log
353 WHERE error_code IN("MY-013595","MY-010069","MY-011810","MY-010116")
354 AND prio<>"System";
355 error_code
356
357 # Likewise, show that log_filter_dragnet affects the table.
358 INSTALL COMPONENT "file://component_log_filter_dragnet";
359 SET PERSIST dragnet.log_error_filter_rules='IF ERR_CODE == ER_SERVER_STARTUP_MSG THEN drop.';
360 UNINSTALL COMPONENT "file://component_log_filter_dragnet";
361 # restart: --log-error-services=log_filter_dragnet;log_sink_internal --log-error=LOG_FILE_D
362 # Show that the variable is there, implying the component was loaded,
363 # and that it's value is as expected.
364 SELECT @@global.dragnet.log_error_filter_rules;
365 @@global.dragnet.log_error_filter_rules
366 IF ERR_CODE == ER_SERVER_STARTUP_MSG THEN drop.
367 # get start-up timestamp from ER_STARTING_AS
368 SELECT COUNT(logged)
369 FROM performance_schema.error_log
370 WHERE error_code="MY-010116"
371 ORDER BY logged DESC LIMIT 1;
372 COUNT(logged)
373 1
374 SELECT logged INTO @startup
375 FROM performance_schema.error_log
376 WHERE error_code="MY-010116"
377 ORDER BY logged DESC LIMIT 1;
378 # show that we filtered out ER_SERVER_STARTUP_MSG
379 SELECT IF(COUNT(*)<>0, "failed: not filtered", "success: filtered")
380 FROM performance_schema.error_log
381 WHERE logged>=@startup AND ERROR_CODE = "MY-010931";
382 IF(COUNT(*)<>0, "failed: not filtered", "success: filtered")
383 success: filtered
384 SELECT *
385 FROM performance_schema.error_log
386 WHERE logged>=@startup AND ERROR_CODE = "MY-010931";
387 LOGGED THREAD_ID PRIO ERROR_CODE SUBSYSTEM DATA
388 RESET PERSIST `dragnet.log_error_filter_rules`;
389 SET @@global.log_error_services=DEFAULT;
390
391 # PERSIST + JSON
392 SET PERSIST log_error_verbosity=1;
393 SET PERSIST log_error_suppression_list="MY-013595,MY-010069,MY-011810,MY-010116";
394 SET PERSIST log_error_services="log_filter_internal; log_sink_json";
395 # restart: --log-error=LOG_FILE_PJ
396 SELECT logged INTO @startup
397 FROM performance_schema.error_log
398 WHERE error_code="MY-010116"
399 ORDER BY logged DESC LIMIT 1;
400 # verbosity=1 (persisted), should apply (and result in 0 notes/warnings)
401 SELECT COUNT(*)=0 FROM performance_schema.error_log
402 WHERE logged>=@startup AND prio NOT IN("Error","System");
403 COUNT(*)=0
404 1
405 # no errors excluded by log_error_suppression_list should appear:
406 SELECT COUNT(*)=0
407 FROM performance_schema.error_log
408 WHERE error_code IN("MY-013595","MY-010069","MY-011810","MY-010116")
409 AND logged>=@startup AND prio<>"System";
410 COUNT(*)=0
411 1
412 # find a row that should exist, and extract JSON data from it
413 SELECT prio,error_code,subsystem,JSON_EXTRACT(data,'$.err_symbol')
414 FROM performance_schema.error_log
415 WHERE logged>=@startup
416 AND LEFT(data,1)='{'
417 AND JSON_EXTRACT(data,'$.err_symbol')="ER_STARTING_AS"
418 ORDER BY logged;
419 prio error_code subsystem JSON_EXTRACT(data,'$.err_symbol')
420 System MY-010116 Server "ER_STARTING_AS"
421 RESET PERSIST log_error_verbosity;
422 RESET PERSIST log_error_suppression_list;
423 RESET PERSIST log_error_services;
424 SET @@global.log_error_services=DEFAULT;
425
426 # RENAME & DROP Error Expected
427 RENAME TABLE performance_schema.error_log to performance_schema.error_log_new;
428 ERROR 42000: Access denied for user 'root'@'localhost' to database 'performance_schema'
429 DROP TABLE IF EXISTS performance_schema.error_log;
430 ERROR 42000: DROP command denied to user 'root'@'localhost' for table 'error_log'
431
432 # restart:
433 SET @@global.log_error_suppression_list=DEFAULT;
434 SET @@global.log_error_verbosity=3;
435 # Done!