Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 226702 - httpd+php+mysql leaves half-open connections to mysql after intense use
Summary: httpd+php+mysql leaves half-open connections to mysql after intense use
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: httpd
Version: 5.0
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: ---
: ---
Assignee: Joe Orton
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2007-02-01 00:42 UTC by George Toft
Modified: 2007-11-30 22:07 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2007-02-05 15:24:47 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description George Toft 2007-02-01 00:42:54 UTC
Description of problem:
httpd + php leave open connections to database server after stress test or heavy
use.


Version-Release number of selected component (if applicable):
httpd-2.2.3-5.el5
php-5.1.6-3
php-mysql-5.1.6-3
php-pdo-5.1.6-3

How reproducible:
Use test tool, such as Jakarta jmeter, to put 50 threads against a simple test
page that pulls back a table from a mysql database.


Steps to Reproduce:
Create simple mysql database on one server.  database has 1 table with 1.6M
bytes of information in 25,000 rows.
Set up apache+php on another server.
Set up jmeter on a web client
Run jmeter against apache.
Watch ESTABLISHED connections to database server from web server
Watch ESTABLISHED connections from web server to database server 

  
Actual results:
After test stops, several connections are open on web server:
[root@rhel5xen1 logs]# netstat -an | grep EST | grep 3306
tcp        0      0 ***.***.76.120:48398          ***.***.75.6:3306            
ESTABLISHED
tcp        0      0 ***.***.76.120:48549          ***.***.75.6:3306            
ESTABLISHED
tcp        0      0 ***.***.120:41543          ***.***.75.6:3306            
ESTABLISHED
tcp        0      0 ***.***.76.120:41052          ***.***.75.6:3306            
ESTABLISHED
[root@rhel5xen1 logs]#

The above was 2 hours after the test finished.  Immediately after the test,
there were 8 of these half-connections.


There are no ESTABLISHED connections on the db server:
[root@RH3-6850 root]# netstat -an | grep EST | grep 3306
[root@RH3-6850 root]#




Expected results:
Expect no ESTABLISHED connections from either end after the test ends.


Additional info:
Sanitized PHP page source:
<html>

<body>

<?php

$db = mysql_connect("***.***.***.***", "dbuser");

if (!$db)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("testdb",$db);

$result = mysql_query("SELECT Name, Account, CID FROM nameaccount",$db);

echo "<table border=1>";

echo "<tr><td>Name</td><td>Account</td><td>CID</td></tr>\n";

while ($myrow = mysql_fetch_assoc($result)) {

        echo
"<tr><td>{$myrow['Name']}</td><td>{$myrow['Account']}</td><td>{$myrow['CID']}</tr>";

}

echo "</table>\n";

mysql_close($db);

?>

</body>

</html>


database summary:
mysql> select count(*) from nameaccount;
+----------+
| count(*) |
+----------+
|    24999 |
+----------+
1 row in set (0.03 sec)

mysql> describe nameaccount;
+---------+--------------+------+-----+---------+-------+
| Field   | Type         | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+-------+
| Name    | varchar(255) | YES  |     | NULL    |       |
| Account | varchar(255) | YES  |     | NULL    |       |
| CID     | varchar(255) | YES  |     | NULL    |       |
+---------+--------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

mysql>

Comment 1 Joe Orton 2007-02-05 15:24:47 UTC
It is expected behaviour that php-mysql leaves database connections open in the
default configuration: see:

  http://www.php.net/manual/en/features.persistent-connections.php

edit the persistence settings in /etc/php.ini to change this.


Note You need to log in before you can comment on or make changes to this bug.