I'm troubleshooting an app that has a lot of sleeping connections to my MySQL (MariaDB) server. I'd like to see just what the queries are on these sleeping connections, but when I run SHOW FULL PROCESSLIST, the Info column holds only NULL.

I suspect theses connections represent long-running queries, but it's a sizeable app, and I'm not sure what parts are creating the offending queries.

Is there a way for me to discover what the queries are?

  • Long-running queries would not be in the sleeping state, obviously. These are idle connections that the application fails to close (or your connection pool is too big). – mustaccio Jun 29 '20 at 18:15

Sleeping connections are not running queries, sleeping connections represent connections that the client/app failed to close successfully, most of the time due to bad programming practices (developers nos closing connections after querying the DB) or bad connectors configuration (not sending a close connection signal or even using an old/outdated connector).

Most of the cases this is not a big issue, but sometimes connection pool can grow out of control a represent a real hazard for real new requests traying to create new connections to the DB, so the best approach to "fix" this issue is to review the application/client and send a close() to the connection or check the connector.

You can also play with wait_ timeout variables to limit the time sleeping connections can remain active.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.