php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13589 Persistent connections stay open and accumulate
Submitted: 2001-10-07 17:33 UTC Modified: 2002-07-10 09:27 UTC
Votes:4
Avg. Score:4.2 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:3 (100.0%)
From: mtremblay at sitebrand dot com Assigned: zak (profile)
Status: Closed Package: MySQL related
PHP Version: 4.0.6 OS: RedHat 7.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git 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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mtremblay at sitebrand dot com
New email:
PHP Version: OS:

 

 [2001-10-07 17:33 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-20 12:31 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.
 [2001-11-20 12:55 UTC] derick@php.net
However, this is something else. This need to be investigated first.
 [2001-12-31 19:08 UTC] zak@php.net
Assigning to myself

 [2001-12-31 19:16 UTC] zak@php.net
doh.

 [2002-07-10 09:27 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.

 [2002-11-30 13:11 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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 21 02:01:35 2024 UTC