php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40681 Unable to close persistent connection
Submitted: 2007-03-01 16:41 UTC Modified: 2007-03-02 05:42 UTC
From: frmi at freemail dot hu Assigned:
Status: Not a bug Package: *Database Functions
PHP Version: 5.2.1 OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: frmi at freemail dot hu
New email:
PHP Version: OS:

 

 [2007-03-01 16:41 UTC] frmi at freemail dot hu
Description:
------------
I must use persistent oci8 connection to oracle, because of high load.
In some cases I want to close the connection and reconnect.
Is it possible somehow?
The oci_close seems not to close the connection.
I understand that the persistent connection was implemented to stay for reuse, but what to do, when it must be closed?


Reproduce code:
---------------
$conn=OCI_connect($user,$pwd,$db);
...
oci_close($conn);
$conn=OCI_connect($user,$pwd,$db);
still uses the old oracle session


Expected result:
----------------
Should disconnect from oracle db, and create a new connection.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-01 16:57 UTC] tony2001@php.net
>In some cases I want to close the connection and reconnect.
Could you please elaborate? What kind of cases?

>what to do, when it must be closed?
One of the reason why persistent connections are called "persistent" is that you cannot close them. 
So if you really need to close the connection and reopen it (I can't imagine why) - don't use persistent connections or restart Apache.
 [2007-03-01 18:09 UTC] frmi at freemail dot hu
>>In some cases I want to close the connection and reconnect.
>Could you please elaborate? What kind of cases?
Sure.
Eg. some mystic behaviour of oracle or the developed system, which can be resolved by simple reconnect, until bug is found and resolved. It happens that it is needed.

>>what to do, when it must be closed?
>One of the reason why persistent connections are called "persistent" is that you cannot close them. 
>So if you really need to close the connection and reopen it (I can't imagine why) - don't use persistent connections or restart Apache.
I cannot belive that. Persistent connection is a choice for enabling a better performance. Eg. keepalive in http. It should not disable the right to disconnect at will.
I think closing the user app is users choice, closing or freeing apps sessions or variables is developers choice.
Restarting apache disturbs other users, while disconnecting just one user doesn't.
I can understand if you say that oci_close must not disconnect the session, but then a oci_pclose would be nice.
 [2007-03-01 18:30 UTC] tony2001@php.net
>Persistent connection is a choice for enabling a better performance. 
>Eg. keepalive in http. It should not disable the right to disconnect at will.

Well, face it then.
I believe you're fixing wrong problem.
You should fix mystic behaviour of oracle first.
 [2007-03-01 19:22 UTC] frmi at freemail dot hu
>I believe you're fixing wrong problem.
>You should fix mystic behaviour of oracle first.
Face what?
Good joke.
Easy to say that instead of telling a solution.
I've such experience, even solved bug in oracle software just surfing source code, but at first waiting few months for the solution from oracle support.
I think oci_pclose would be good, no reason of not having that.
And it is a bit easier then solving all oracle bugs.
 [2007-03-01 19:38 UTC] frmi at freemail dot hu
It's unfriendly to set status to bogus without having reason for that.
Even the documentation says that starting from the version 1.1 oci_close() correctly closes the Oracle connection.
Not mentioning that it is not true for persistent connection.
Please be collaborative.
 [2007-03-01 19:47 UTC] tony2001@php.net
>Even the documentation says that starting from the version 1.1
>oci_close() correctly closes the Oracle connection.
>Not mentioning that it is not true for persistent connection.

All persistent connections are not affected by *_close() functions, it's not something OCI8 specific.
MySQL persistent connections cannot be closed by mysql_close() etc. etc.
PHP behaves this way since the very introduction of persistent connections, and I doubt this is a subject to change in the future, since it'd destroy whole concept of "persistency".
Hence the status of the report.

 [2007-03-02 05:42 UTC] frmi at freemail dot hu
OK.
I see I'll have no success with you.
But you are surely wrong.
The base concept is ok, but it is a little confusing.
If there is pconnect, then there should be pclose.
No place to doubt.
If the concept is sooooo persistent as you say,
and really there must be no pclose, then there must be no pconnect.
I could understand this as well.
Then the connection could be a configured one and it would be opened when trying to use it, or at script startup.
But I think this would be topo strong.
I cannot understand why a pclose would destroy concept of persistency.
It is simply not true.
And the problem is, that with denying a small bit of code to complete the concept, there are lots of problems which cannot be handled.
 [2014-03-06 12:44 UTC] narf at devilix dot net
Not a bug?! Are you for real?!

If I tell PHP to close a connection, it MUST close it. In fact, *_close() is pretty much useless for non-persistent connections - I can just leave PHP to close them at the end of script execution.

I'm not sure if this hasn't been fixed already though, considering that it was reported for PHP 5.2.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 24 19:01:32 2024 UTC