Edit report at https://bugs.php.net/bug.php?id=55473&edit=1

 ID:                 55473
 Comment by:         littlesavage at rambler dot ru
 Reported by:        littlesavage at rambler dot ru
 Summary:            mysql_pconnect leaks file descriptors on reconnect
 Status:             Open
 Type:               Bug
 Package:            MySQL related
 PHP Version:        5.3.7
 Block user comment: N
 Private report:     N

 New Comment:

I have found this bug on Debian squeeze (x86_64), php PHP 5.3.6-6~dotdeb.1 with 
Suhosin-Patch, mysql 5.1.58.
Then i repeat it on FreeBSD 9, php 5.3.7 with Suhosin-Patch, mysql 5.5.12.

On FreeBSD i have found that this bug reproducable only when i use mysqlnd 
native driver. Everything work as expected with standart mysql driver.


Previous Comments:
------------------------------------------------------------------------
[2011-08-22 03:05:27] larue...@php.net

I can't reproduce this bug in PHP-5.3.7 on Linux Redhat(64-bit).
What's your OS type?

------------------------------------------------------------------------
[2011-08-21 10:52:44] littlesavage at rambler dot ru

Description:
------------
Whem Mysql closes created by mysql_pconnect() peristent connection, file 
descriptor lefts opened and is never reused.
I have a server that stops working due to opened file descriptors limit.

Test script:
---------------
<?php

function connect($passwd) {
   $conn = mysql_pconnect('localhost:3306','root', $passwd);
   if (!$conn)
      die(mysql_error()."\n");
   mysql_query("set wait_timeout=5", $conn);
   return $conn;
}

$passwd = $argv[1];
$conn = connect($passwd);

for($i=0;$i<10;$i++) {
   /* wait while mysql closes connection */
   sleep(6);

   if (!mysql_ping($conn)) {
      echo "reconnect\n";
      $conn = connect($passwd);
   }

   $r = mysql_query('select 1', $conn);
   $error = $r ? 'OK' : mysql_error();
   $opened_files = trim(exec("lsof -np " . getmypid() . " | wc -l"));
   echo "$error. opened files: $opened_files\n";
}

?>


Expected result:
----------------
$ php ./test.php
reconnect
OK. opened files: 76
reconnect
OK. opened files: 76
reconnect
OK. opened files: 76
reconnect
OK. opened files: 76
...

Actual result:
--------------
$ php ./test.php
reconnect
OK. opened files: 76
reconnect
OK. opened files: 77
reconnect
OK. opened files: 78
reconnect
OK. opened files: 79
...


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=55473&edit=1

Reply via email to