Hello,
I have a web app which connect to MySQL server. When i get many times the error “1040 - Too many connections” from MySQL then, the web app becomes unresponsive and needs to get restarted otherwise it will remain stucked.
How should i handle this error?
If the web app is unresponsive because of MySQL (too many connections) and the MySQL connect again the web app will never come back. It needs restart.
Is this the way that the framework handles this error or we can do something in our code to handle this?
You may want to look into why your web app needs so many connections in the first place. Does the number of concurrent sessions really exceed maxconnections or does maybe your webapp create new connections all over the place without closing or reusing the previous ones? If you really have so many sessions you might have to use a connection pool.
Are you creating a new database connection within every method? I so, I recommend creating it once then using the one connection multiple times, checking it is still alive before using it.