PHP Bugs  
php.net | support | documentation | report a bug | advanced search | search howto | statistics | login

go to bug id or search bugs for  

Bug #13589 Persistent connections stay open and accumulate
Submitted:7 Oct 2001 5:33pm UTC Modified: 10 Jul 2002 9:27am UTC
From:mtremblay at sitebrand dot com Assigned to:zak
Status:Closed Category:MySQL related
Version:4.0.6 OS:RedHat 7.1
Votes:4 Avg. Score:4.2 ± 0.8 Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%) Same OS:3 (100.0%)
View/Vote Developer Edit Submission

Welcome! If you don't have a SVN account, you can't do anything here. You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
SVN Username: SVN Password:
Quick Fix:
Status: Assign to:
Category:
Summary:
From: mtremblay at sitebrand dot com
New email:
Version: OS:
New/Additional Comment:

[7 Oct 2001 5:33pm UTC] mtremblay at sitebrand dot com
While trying to use persistent connections for performance on an ad
server, connections to the MySQL server stay open and accumulate over
time until it hits the max_connections setting is hit. Once this
happens, MySQL refuses to allow connections.

After looking at the MySQL process list, it seams that connections are
not always recycled. In theory, idle established connections' Commands
should be "Sleep" but curiously, it looks like connections not being
recycled have "Query" command and a state of "NULL".

Presently using MySQL 3.23.36.
[20 Nov 2001 12:31pm UTC] sander@php.net
This is what Derick said about this (in #14149):
This is not a bug, the MySQL extension will open a new connection if the
_current apache child_ has no open connection to MySQL.
With this in mind, it's very normal to see that apache has multiple
connections open to MySQL.
[20 Nov 2001 12:55pm UTC] derick@php.net
However, this is something else. This need to be investigated first.
[31 Dec 2001 7:08pm UTC] zak@php.net
Assigning to myself
[31 Dec 2001 7:16pm UTC] zak@php.net
doh.
[10 Jul 2002 9:27am UTC] georg@php.net
To fix this problem, you should set your mysql-server 
variable timeout_interactive to the number of seconds 
(default is 28800).

For pconnect use the optional 4th parameter client_flags:
mysql_pconnect($host, $user, $pass, 
MYSQL_CLIENT_INTERACTIVE);

This allows interactive_timeout seconds (instead of 
wait_timeout seconds) of inactivity before closing the 
connection. 

This new optional parameter is available in the latest 
CVS-tree.
[30 Nov 2002 1:11pm UTC] diegoefe at yahoo dot com
I have the same problem running version 4.2.3 on a FreeBSD 4.6.2.
And I check the problem running this script:
<?
$con = mysql_connect('localhost','user','pass');
mysql_select_db('midb',$con);

$q = "Select * from categorias order by nombre limit 5";
$res = mysql_query($q,$con);
while($r = mysql_fetch_array($res,$con))
{
	print "<p>".$r['nombre']."</p>";
}
print "<hr>";

$q = "Select * from vinculos order by nombre limit 5";
$res = mysql_query($q,$con);
while($r = mysql_fetch_array($res,$con))
{
	print "<p>".$r['nombre']."</p>";
}
print "<hr>";
mysql_close($con);
?>

and checking the mysql client console with:
mysql> show status like "%onnection%";

and Max_used_connections incrementes like if the mysql_close didn't
exists.

RSS feed | show source 

PHP Copyright © 2001-2009 The PHP Group
All rights reserved.
Last updated: Sat Nov 21 10:30:49 2009 UTC