ID:               39029
 User updated by:  kiranm at hp dot com
 Reported By:      kiranm at hp dot com
-Status:           Bogus
+Status:           Open
 Bug Type:         OCI8 related
 Operating System: HP-UX
 PHP Version:      5.1.6
 New Comment:

>From the documentation, I understand that the timeout directive is to
be used to provide the length of idle time after which the connection
will be terminated (if there are no active connections).

So when I use 10 secs as the timeout and issue a request after say 60
seconds, shouldnt the existing connection be terminated and a new one
opened ? That is not happening. The old one continues to be used no
matter what.


Previous Comments:
------------------------------------------------------------------------

[2006-10-03 19:43:35] [EMAIL PROTECTED]

>After the timeout of 10 secs, when I run netstat again, 
>I find all the connections still open.
Sure, they won't just disappear magically.
Connections are closed at extension shutdown, if extension is not used
they will be still there.

>So that part of the code does not get executed
>when there is already an open connection even when the >timeout has
expired.
Yes, that's the whole point (see http://php.net/oci8):
---
oci8.persistent_timeout int

The maximum length of time (in seconds) that a given process is allowed
to maintain an idle persistent connection. Setting this option to -1
means that idle persistent connections will be maintained forever.
---

>I changed it on my machine and it works as expected.
No, persistent connections are NOT expected to be closed if they are
still being used.

No bug here, this is the expected behaviour.


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

[2006-10-03 19:30:45] kiranm at hp dot com

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 this bug report at http://bugs.php.net/?id=39029&edit=1

Reply via email to