Bug #67132 Provide more detailed connection error status variables to aid debugging
Submitted: 8 Oct 2012 11:58 Modified: 4 Feb 2013 21:39
Reporter: Simon Mudd Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Errors Severity:S3 (Non-critical)
Version:all OS:Any
Assigned to: Marc ALFF CPU Architecture:Any
Tags: windmill

[8 Oct 2012 11:58] Simon Mudd
Description:
When experiencing connectivity problems between a client and a mysql server it can often be very hard to diagnose the EXACT reason for these problems. There are 2 status variables which provide information (see http://dev.mysql.com/doc/refman/5.6/en/server-status-variables.html) and these are:

Aborted_clients
Aborted_connections

yet reading the associated text it becomes obvious that the number of different reasons for these errors is quite varied:

Aborted_clients (3 different reasons stated)
Aborted_connections (4 specific reasons stated)

There are also some common reasons for issues.

So if you need to diagnose an occasional problem reaching a server the statistics there are usually not as complete as one would like. The problem may not be the mysql server at all but a network, firewall, client (software), or client (behaviour) issue, but this is not clear.

There are hundreds of general questions and queries about things like "MySQL has gone away" when a client loses a connection but there is also a better need to determine if a failed connection (especially one with a connect timeout) fails as diagnosing this type of error, especially if it is very intermittent is really hard, and traffic sniffing hours of "success connections" to look for the single failure is really hard.

So I think more detailed statistics of "unclean" connects or disconnects would be most useful.

How to repeat:
Make lots of connects to a mysql server and intermittently trigger problems by doing things like disconnect the network, or kill the connecting clients. Now try to figure out some of the different reasons for these unclean connects based on the status variables.  There is some logging but there's not much detail in the way of the status variables. Also logging provides an attack vector which could fill up a log file so it's often not good to log too much (under normal circumstances).

Suggested fix:
It would be most useful if more status variables could be added which would include the appropriately more detailed reasons (maintaining the current ones for backwards compatibility) so that diagnosis of issues like this could be made much better.

The actual reporting of errors to the client could also be improved to help identify the causes of certain issues. This may not necessarily require the error codes to change but simply the error text providing a more specific description of the cause.
[8 Oct 2012 11:59] Simon Mudd
Would be nice to see this in 5.6 :-)
[8 Oct 2012 12:36] MySQL Verification Team
Thank you for the bug report.
[12 Oct 2012 9:12] Marc ALFF
Please see the performance_schema.host_cache table.
[15 Oct 2012 9:21] Simon Mudd
It's nice to see this new facility in MySQL 5.6.
Thanks for the pointer. This does indeed seem to contain a much more precise information as to connection errors and probably should help me identify the issues I was trying to diagnose.
[4 Feb 2013 21:39] Marc ALFF
Implemented in MySQL 5.6 by table performance_schema.host_cache.