elian wrote:
While learning PHP I came across the following warning in the php manual and remembered one frequent error message in wikipedia (maximum number of database connections exceeded...):
There are a couple of additional caveats to keep in mind when using persistent connections. One is that when using table locking on a persistent connection, if the script for whatever reason cannot release the lock, then subsequent scripts using the same connection will block indefinitely and may require that you either restart the httpd server or the database server.
...
Do we actually use persistent connections
Yes...
and is this problem affecting wikipedia?
Mmm, sort of. We don't do any explicit table locking (ie, something like "LOCK TABLE cur"); tables are locked implicitly during queries, and locks should be automatically released when the query finishes even if our PHP script has meanwhile died and gone to process heaven, since there's no need to run an UNLOCK.
What does bite us sometimes is that a mysql connection can get stuck in an intermediate state between read calls where we end up being unable to do anything useful with it (you get "commands out of order" errors). You can't mysql_close() a persistent connection, and I haven't figured out a way to get out of the stuck state, so we have to do a new non-persistent mysql_connect() every time the Apache thread with the broken connection is reused. It's kinda inefficient, but it doesn't block the whole server.
-- brion vibber (brion @ pobox.com)