I\'m having a weird issue using Zend_Db\'s PDO adapter for managing my database connections. All of a sudden, I\'m constantly hitting the connection limit on my MySQL server
Our Zend application has also been leaving quite a few connections open. They tend to come in spurts, but we never did figure out what was going on. We worked around the problem by setting max_connections
high (which we needed for other reasons, anyway) and reducing wait_timeout to two hours. We could have gotten away with a much lower timeout, but didn't want to risk the real application once we stopped seeing failures.
Did you try to manually close the connection? This seems to be a specific problem.
$db->closeConnection();
Ref: http://framework.zend.com/manual/en/zend.db.adapter.html#zend.db.adapter.closing
15.1.8. Closing a Connection
Not sure if this is of any use to you but this link gives you a (temporary) good description of the issue you are experiencing as well as a --max_connect_errors setting which you could override:
http://developer.spikesource.com/wiki/index.php/Question:mysqladmin_host_blocked_because_of_many_connection_errors
A user also responds and recommended trying the following on the command line:
> mysqladmin -u <user> -p<password> processlist
This will give you a list of your current mysql connections to get an idea for how many concurrent connections you are currently running. Again, these aren't solutions per say, but hopefully they get you a step closer to solving the dropped connection issue.
Don't think it's related to properly closing connection. http://dev.mysql.com/doc/refman/5.0/en/blocked-host.html says that it rather a problem with network layer.
I think one of your script is running an ultra long query or get stuck ?
The best solution would be to create a logging tool and use that to know where exactly the problem is.
The Zend_Log classes should help you to write that logging tool, obviously you have better to user a file writer and not a DB one. Since your problem is DB related you should create or modify the DB class to emit some logs.
I don't know the volumetric of your project but it might have some performance side effects.
Also playing with the long query feature of MySQL would probably give you some hint.
Hope you are going to find where is your problem.
first i'll ask: do you have any new core-dumps? (check apache error log).
second: from my grim experience having too many connections to the database usually means that you have too many apache processes not dieing properly. Usually this is caused by some long-running process, memory locks, etc. try to strace
some of your apache processes and see if they hang somewere or do endless loops.
Unless you have a significant increase in traffic you should not suffer from too-many-connection problems