PHP 4.0 Bug #9252: Bad database name leaves open connection
| From: | supporter-rwidmer at support dot zend dot com | Date: | Wed, 14 Feb 2001 10:03:00 +0000 |
| Subject: | PHP 4.0 Bug #9252: Bad database name leaves open connection | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-46539@lists.php.net to get a copy of this message | ||
From: supporter-rwidmer@support.zend.com
Operating system: Linux and FreeBSD 4
PHP version: 4.0.4pl1
PHP Bug Type: MySQL related
Bug description: Bad database name leaves open connection
A Zend Help Desk customer (54) reported having an unreasonable number of connections to his database
server in TIME_WAIT or CLOSE_WAIT state. On closer inspection it was found that the database name
passed to mysql_selectDB was invalid. Correcting the database name appears to have hidden the
problem again.
This became a major problem on his heavily loaded site because all the available Apache processes
ended up waiting for database connections to close and made the server unavailable. He is using
Apache 1.13.14/PHP 4.04 on one server and MySQL 3.23.32 on
another.
I am able to reproduce the problem on PHP4.0.2PL1 on SuSE Linux 6.3 using MySQL 3.22.25. I do get
an error back from the mysql_selectDB() call, but the network connection to the database server
stays open for a minute or so, in a TIME_WAIT state. Connecting to the same database server, with
the same username and password using the mysql command line interpreter, then attempting to use an
invalid database name does not result in hanging connections.
The following script will demonstrate the problem:
---------------------------------------
<?
mysql_connect( $host, $user, $password )
or die( 'Unable to Connect - ' . mysql_error());
mysql_selectDB( 'invalid database name' )
or die( 'Unable to Select - ' . mysql_error());
?>
All done
---------------------------------------
Set $host, $user, $password to a MySQL database on another machine, then hit this program a few
times with your browser. It ends properly in the die() for Unable to Select, but you will find that
it leaves network connections to the database server open in TIME_WAIT state for about a minute
after the script dies. You can verify this with
netstat -na
--
Edit Bug report at: http://bugs.php.net/?id=9252&edit=1