#33624 [Fbk->Csd]: pdo_odbc does not close connections

From: Date: Sun, 10 Jul 2005 14:58:08 +0000
Subject: #33624 [Fbk->Csd]: pdo_odbc does not close connections
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-81634@lists.php.net to get a copy of this message
ID: 33624 Updated by: wez@php.net Reported By: gpd at gpdnet dot co dot uk -Status: Feedback +Status: Closed Bug Type: PDO related Operating System: Windows XP/IIS PHP Version: 5CVS-2005-07-09 (dev) New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2005-07-10 15:26:58] 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 11:25:37] 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-09 20:53:30] 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-09 20:19:37] 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'); ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33624&edit=1

« previous php.bugs (#81634) next »