Bug #80546 [NEW]: Persistent connections appear open despite being closed

From: Date: Tue, 22 Dec 2020 21:17:33 +0000
Subject: Bug #80546 [NEW]: Persistent connections appear open despite being closed
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231224@lists.php.net to get a copy of this message
From: jeremys at ha dot com Operating system: RHEL 7.8 PHP version: 7.3.25 Package: PDO DBlib Bug Type: Bug Bug description:Persistent connections appear open despite being closed Description: ------------ Because PHP_DBLIB doesn't implement pdo_dbh_check_liveness_func (its value is null, which is "equivalent to returning SUCCESS"), when instantiating a new PDO object using persistent connections with dblib, if the connection dies, PHP is not aware of it and any subsequent queries using the connection fail with "DBPROCESS is dead or not enabled". pdo_dbh_check_liveness_func definition: https://github.com/php/php-src/blob/caa710037e663fd78f67533b29611183090068b2/ext/pdo/php_pdo_driver.h#L264 pdo_dblib's implementation: https://github.com/php/php-src/blob/caa710037e663fd78f67533b29611183090068b2/ext/pdo_dblib/dblib_driver.c#L417 In this specific example, a Microsoft SQL Server is used to simulate a connection timeout using the WAITFOR DELAY query (which causes the connection to be considered dead by dblib). Connection is made using FreeTDS 1.1.x. Based on the source, seems to be an issue in PHP 8 as well. Test script: --------------- <?php for( $i = 0; $i <= 1; $i++ ) { $pdo = new PDO( 'dblib:dbname=northwinds;host=contoso', 'username', 'password', [ PDO::ATTR_PERSISTENT => false, PDO::ATTR_TIMEOUT => 5 ] ); try { if( $i == 0 ) { $pdo->query( "WAITFOR DELAY '00:00:10'" ); } var_dump( $pdo->query( "SELECT 'output' AS Output" )->fetch( PDO::FETCH_ASSOC )['Output'] ); } catch( Throwable $e ) { var_dump( stripos( $pdo->errorInfo()[2], 'DBPROCESS is dead or not enabled' ) === 0 ); } $pdo = null; } ?> Expected result: ---------------- bool(true) string(6) "output" Actual result: -------------- bool(true) bool(true) -- Edit bug report at https://bugs.php.net/bug.php?id=80546&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=80546&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=80546&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=80546&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=80546&r=needscript Try newer version: https://bugs.php.net/fix.php?id=80546&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=80546&r=support Expected behavior: https://bugs.php.net/fix.php?id=80546&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=80546&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=80546&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=80546&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=80546&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=80546&r=dst IIS Stability: https://bugs.php.net/fix.php?id=80546&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=80546&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=80546&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=80546&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=80546&r=mysqlcfg

« previous php.bugs (#231224) next »