From: kiranm at hp dot com Operating system: HP-UX PHP version: 5.1.6 PHP Bug Type: OCI8 related Bug description: Persistent connections remain even after timeout has elapsed
Description: ------------ I have a small script : <html> <body> <?php $db = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP) (HOST = <oracleserver>)(PORT=1521)) (CONNECT_DATA=(SERVER=DEDICATED) (SERVICE_NAME=TEST)))"; $connection = oci_pconnect("scott","tiger",$db); $stmt = OCIParse($connection, "select * from ALL_USERS"); OCIExecute($stmt); while(OCIFetch($stmt)) echo OCIResult($stmt,"USERNAME")."<BR>\n"; echo "\n"; ?> </body> </html> I use the Apache worker model. The php.ini file has the following parameters set : [Oci8] oci8.max_persistent=1 oci8.persistent_timeout=10 oci8.ping_interval=0 When I use the Apache bench (ab) tool to run the above script 1000 times, I get about 50 connections opened with Oracle. I tested this by executing : netstat -an | grep 1521 After the timeout of 10 secs, when I run netstat again, I find all the connections still open. When I reissued the ab request, I found that no new connections are established and that the old connections were used. I used tusc/truss tool to check this out. Reproduce code: --------------- I went through the code and did not find any active housekeeping that is done to terminate connections that have passed the timeout. The decision to use an existing connection or a new connection seems to be something that is made when there is a new request. In the php_oci_persistent_helper() function, I found that connection->idle_expiry is compared with the timestamp only when the connection is not used. So that part of the code does not get executed when there is already an open connection even when the timeout has expired. I think this check should be made always otherwise persistent connections will continue to get used. I changed it on my machine and it works as expected. Expected result: ---------------- Persistent connections should expire after timeout or at the least when there is a new request after the timeout period has elapsed. Actual result: -------------- Persistent connections continue to exist and be used even after the specified timeout. -- Edit bug report at http://bugs.php.net/?id=39029&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39029&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39029&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39029&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=39029&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=39029&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=39029&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=39029&r=needscript Try newer version: http://bugs.php.net/fix.php?id=39029&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=39029&r=support Expected behavior: http://bugs.php.net/fix.php?id=39029&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=39029&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=39029&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=39029&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39029&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=39029&r=dst IIS Stability: http://bugs.php.net/fix.php?id=39029&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=39029&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=39029&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=39029&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=39029&r=mysqlcfg