php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33624 pdo_odbc does not close connections
Submitted: 2005-07-09 20:19 UTC Modified: 2005-07-10 16:58 UTC
From: gpd at gpdnet dot co dot uk Assigned:
Status: Closed Package: PDO related
PHP Version: 5CVS-2005-07-09 (dev) OS: Windows XP/IIS
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: gpd at gpdnet dot co dot uk
New email:
PHP Version: OS:

 

 [2005-07-09 20:19 UTC] gpd at gpdnet dot co dot uk
Description:
------------
In the latest 5.1 snapshots the pdo_odbc driver does not close connections to the database server.

run the below code mulitple times by re-requesting the page.

After several requests there are lots of idle connections at the database server

Tried this with odbc connection pooling on and off.

Tried this with SQLServer and Sybase SQLAnywhere. After a while running my code there are hundreds of connections on the server, even after leaving for an hour.

Only killing the dllhost process will free the connections

Even explicitly assigning null to the connection recource does not disconnect.

Reproduce code:
---------------
$cn = new PDO('odbc:DRIVER={SQL Server};Server=GARY;Database=cct8740','sa','ashwell');




Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-09 20:53 UTC] wez@php.net
Hmmm, I turned that off on my local environment because it would crash during shutdown, 100% of the time.
I've enabled it again in the snaps; if it doesn't blow up for you in the next snapshot, then it seems the problem is specific to my machine.
 [2005-07-10 11:25 UTC] gpd at gpdnet dot co dot uk
That's bizarre. If I have connection pooling off, dllhost crashes immediately. If I have connection pooling on, the connection is closed at the end of the script so the connection keeps getting re-used with no problems. 30 secons later, after stopping the test, dllhost crashes. 30 Seconds is my connection pool timeout setting for the SQLServer driver! So it is not crashing when the connection is logically closed by pdo, but when it is physically disconnected from the server.

Either way is unworkable. Currently the web app stop working fairly rapidly. Disabling the pdo disconnects just means the entire server falls over later because of a huge mass of stale connections.

NOTE: I DO NOT see this behaviour with Sybase SQLAnywhere!!! Whatever settings I use it is perfectly stable with the latest php snapshot.

It may well be a bug in the SQLServer ODBC, or a bug in pdo that does not trigger the same issue with SQLAnywhere, but pdo USED to work with SQLServer, so it must be some recent changes that have triggered the problem.
 [2005-07-10 15:26 UTC] wez@php.net
So, PDO_ODBC and the SQLAnywhere driver is ok for you?
I've tried the following, and all crash on shutdown:

- MS Access
- SQL Server
- SQL Server Native (from SQL Server 2005 beta)

PDO_ODBC + DB2 client libraries under linux works perfectly.  

Which is the last version of PHP/PDO you tried that didn't have the crash?

 [2005-07-10 16:58 UTC] wez@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Very subtle:

        rc = SQLSetConnectAttr(H->dbc, SQL_ATTR_AUTOCOMMIT,
-               (SQLPOINTER)(dbh->auto_commit ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF), SQL_NTS);
+               (SQLPOINTER)(dbh->auto_commit ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF), SQL_IS_INTEGER);

Seems that the MS drivers literally believed that the autocommit flag was a string, when it was actually an integer value.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 12:01:30 2024 UTC