Remy
Remy

Reputation: 12703

Debugging MySQL: Too many connections

After we deployed the new version of our ASP.NET C# app with a MySQL DB we are having issues with the connections.

Yesterday I got the "Too many connections" error and I'm watching the open connections with SHOW FULL PROCESSLIST and they keep increasing during the day.

Is there a good way to figure out where our bug could be? Like checking the last query that a sleeping connection made?

Upvotes: 0

Views: 1701

Answers (2)

0xCAFEBABE
0xCAFEBABE

Reputation: 5666

Connection pooling usually solved this problem. In your case, connections seem to stay open much too long, which means that in some branches of your software, there's not definitive finally that closes the connection after it has been used. It's especially useful to diagnose problematic connection usage at a central point, because it can keep an eye on the number of open connections at any given time and maybe alert somebody to make a dump to analyze later.

You could also increase the number of connections allowed to your MySQL instance. The settings in your my.cnf is "max_connections".

Lastly, if you want you can try to decrease the "wait_timeout" or "interactive_timeout" properties of your instance. These settings regulate atomatic closing of connections after certain amounts of time.

Upvotes: 1

Fathah Rehman P
Fathah Rehman P

Reputation: 8741

Make sure your app is closing connection to db properly....if your app not closing connections then you will get above error

Upvotes: 2

Related Questions