Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql aborted connections -- how to track down cause

Tags:

php

mysql

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        |
like image 790
Chris Muench Avatar asked Mar 19 '23 14:03

Chris Muench


1 Answers

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.

like image 164
Alex.Ritna Avatar answered Mar 22 '23 04:03

Alex.Ritna