Bug #90680 dragnet logging: document how to use / find error_symbol codes
Submitted: 29 Apr 2018 8:07 Modified: 26 Oct 2018 1:42
Reporter: Simon Mudd (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S4 (Feature request)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: documentation, dragnet, loggigng, symbolic error codes

[29 Apr 2018 8:07] Simon Mudd
Description:
I have setup some rules as follows:

myuser@myhost [(none)]> select @@dragnet.log_error_filter_rules; 
+-----------------------------------------------------------------------------------------------------------------------------------------+ 
| @@dragnet.log_error_filter_rules | 
+-----------------------------------------------------------------------------------------------------------------------------------------+ 
| 
IF err_code == 10927 or err_code == 10914 or err_code == 10926 then drop. 
IF err_code == 999 then drop. 
IF err_code == 1234 then drop. | 
+-----------------------------------------------------------------------------------------------------------------------------------------+ 
1 row in set (0.00 sec) 

but of course no-one is likely to remember error codes so using error codes is not good.

I hear though that the perror command now provides this information which can be used to improve the readability of the error messages.  See: https://dev.mysql.com/doc/refman/8.0/en/perror.html. This may not be known to many people.

[myuser@myhost ~]$ perror 10927
MySQL error code MY-010927 (ER_ACCESS_DENIED_FOR_USER_ACCOUNT_LOCKED): Access denied for user '%-.48s'@'%-.64s'. Account is locked.
[myuser@myhost ~]$ perror 10914
MySQL error code MY-010914 (ER_ABORTING_USER_CONNECTION): Aborted connection %u to db: '%-.192s' user: '%-.48s' host: '%-.64s' (%-.64s).
[myuser@myhost ~]$ perror 10926
MySQL error code MY-010926 (ER_ACCESS_DENIED_ERROR_WITH_PASSWORD): Access denied for user '%-.48s'@'%-.64s' (using password: %s)

So the first line (which has real error codes) could be translated to:

IF err_code == ER_ACCESS_DENIED_FOR_USER_ACCOUNT_LOCKED or err_code == ER_ABORTING_USER_CONNECTION or err_code == ER_ACCESS_DENIED_ERROR_WITH_PASSWORD then drop.

This is slightly longer but much clearer.
My understanding is these rules are compiled so there's no performance overhead of using the symbolic names vs the error codes.

How to repeat:
See above.

Suggested fix:
Document this so that people follow this as a best practice (using symbol names not error numbers) . It just makes things easier later on to diagnose bugs that may arise due to typos etc
[26 Oct 2018 1:42] Paul DuBois
Posted by developer:
 
Updated to illustrate use of perror:
https://dev.mysql.com/doc/refman/8.0/en/error-log-filtering.html#error-log-filtering-langu...