php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18551 multiple pconnect => too many established TCP connection
Submitted: 2002-07-24 18:52 UTC Modified: 2002-07-25 05:56 UTC
From: tl at ccf dot fr Assigned:
Status: Closed Package: MySQL related
PHP Version: 4.2.2 OS: windows 2000
Private report: No CVE-ID: None
 [2002-07-24 18:52 UTC] tl at ccf dot fr
PHP is running as apache module (apache version 2.0.39)

Multiple call to mysql_Pconnect on same mysqldb host
with eachtime same host,user and password parameters  cause in somecase to return different php ressourceID.

So, as persistent connection on php apache module will be available until thread die, (silently) more and more opened connection to mysql are made.

After a certain time, it causes apache to stop to serve http request (without apache2 service die) with an "Cannot get free socket to listen on 0.0.0.0:80) because at this time, it seems there is too many TCP ESTABLISHED state connection between apache and mysql (near 80 on my system).

Trying to play with multithreading apache configuration, can delay this problem (serveral hours), but not resolve it;Same for apache keepalive sets to on or off.

The only way I found to avoid this trouble is just use non-persistent connection. 
In this case I can observe that there is always one uniq ressource id for the same host, user and password mysql_connect.

PS: Mysql and apache on the same computer.
Mysql, apache and php timeouts configurations are all sets by default. Mysql, apache and php are newer installion on a newer W2000 computer.




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-25 05:56 UTC] georg@php.net
Please download the current CVS version and use mysql_pconnect with the optional parameter client_flags:
mysql_pconnect($user, $password, $host, MYSQL_CLIENT_INTERACTIVE);

This forces mysql to close idling persistent connections. You  have to set the variable interactive_timeout in your my.cnf (300 should be ok).
 [2002-10-08 18:04 UTC] maillists at conactive dot com
Are you sure that this flag is the right cure? I see the same with PHP 4.2.2 on Windows via Apache 1.3.26. However, this does NOT occur when using the same PHP setup over IIS. So, this seems to indicate for me that the problem is actually with the php4apache.dll or with Apache.
 [2002-11-04 15:25 UTC] levik at levik dot com
I have the same problem on linux. Tried various configurations, using both builtin and external MySQL libraries, but the problem persists. I *KINDA* worked around it by setting a high connection limit for mysql, and a low timeout value. This way, unused connections die quicker. However this is murder on mem usage.

I *never* see connection count in phpinfo() go above 1, even though persistent connections are on, and limited to 40. (Total connections limited at 90). php seems to ignore these settings, as "show processlist" in mysql shows 100 - 200 idle connections depending on traffic load.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 01 11:01:33 2024 UTC