Question

I am trying to debug a problem in PHP and I think I found a likely culprit. Mysql has aborted connections.

Is there anything in mysql logs that will help me pinpoint where the connection was dropped/why? (I have seperate DB + web Servers)

mysql> SHOW GLOBAL STATUS;
+------------------------------------------+--------------+
| Variable_name                            | Value        |
+------------------------------------------+--------------+
| Aborted_clients                          | 150          |
| Aborted_connects                         | 86496        |
Was it helpful?

Solution

Aborted_connects are clients who attempt to connect and fail. Usually this is because of incorrect credentials (wrong password or no matching host for the user).

I would start by turning on --log-warnings as mentioned in the documentation and checking your error logs to help find the culprit of frequent connection failures.

Aborted connections can also be caused by clients trying to connect with invalid or malformed connection strings. Some monitoring applications for example just check the mysql port for connectivity and can trigger this. This blog post has some examples of using packet level monitoring to try and pinpoint the issue.

Aborted_clients are the client not closing the connection properly. PDO and MySQLi both provide methods to correctly close a scripts connection when it's done.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top