开发者

Kohana 3 and the "Too many connections" error

开发者 https://www.devze.com 2023-04-06 09:44 出处:网络
I have a web application in production that manages an internal system and a web page, both in relation. Not only as a CMS+Web, both works like a user-control-system, requests-management, CMS and web.

I have a web application in production that manages an internal system and a web page, both in relation. Not only as a CMS+Web, both works like a user-control-system, requests-management, CMS and web. Both systems have too many users (admins, editors and final-users). The system uses MySQL as DB engine.

So, you are in context now.

I had the following SQL error;

Database_Exception [ 0 ]: [1040] Too many connections ~ MODPATH/database/classes/kohana/database/mysql.php [ 67 ]

Looking at the server side, it's real, the server had too many connections to the DB Engine. The message is right.

The website was 开发者_高级运维down. I restart Apache and everything works fine. But obviously this would ever happen.

I'm googling and reading the MySQL manual and see that exists a configuration to increase the connections number (from 151, the default, to another value). But, I'm reading about the Kohana config and I read that exists a queries caché system (into the database configuration file). So, I don't know if that cache "saves" in memory the query result or it the cache "saves" the query itself to prevent the overload of Query_Builder or ORM, so if the query had been previously generated don't re-generate it and only execute it.

I need a solution but avoiding (as possible as it could be) the MySQL config modification.

Thanks!


Check your setting of max_connections in the mysql config file my.ini. The default setting is 100, you may change it to 300 or more.

Then, look what processes are connected to mysql with the command netstat -np, and kill unknown ones.

After all changes restart you mysql daemon:

/etc/rc.d/init.d/mysqld restart

If this doesn't help, read: http://dev.mysql.com/doc/refman/5.5/en/too-many-connections.html

And do not forget make dumps for all mysql dbs.

0

精彩评论

暂无评论...
验证码 换一张
取 消