简体   繁体   中英

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?

确保您的应用程序正确关闭了与数据库的连接。...如果您的应用程序未关闭连接,则将收到上述错误

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM