Bug #78982 [NEW]: pdo_pgsql returns dead persistent connection

From: Date: Tue, 17 Dec 2019 17:38:49 +0000
Subject: Bug #78982 [NEW]: pdo_pgsql returns dead persistent connection
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224363@lists.php.net to get a copy of this message
From: kentaro at ranvis dot com Operating system: PHP version: master-Git-2019-12-17 (Git) Package: PDO PgSQL Bug Type: Bug Bug description:pdo_pgsql returns dead persistent connection Description: ------------ When PDO::ATTR_PERSISTENT is true, PDO tells a driver to check if the connection is still alive. For PDO PgSQL driver, this is done in pdo_pgsql_check_liveness(). It calls PQstatus() to see if the status is good, but since PQstatus() only returns the previous status stored locally, the driver cannot tell if the connection is actually alive. This results in returning possible dead connection to the script. will add a PR. Test script: --------------- <?php $connArgs = ['pgsql:dbname=DB_NAME', 'USER', 'PASSWORD', [ PDO::ATTR_PERSISTENT => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, ]]; $pdo = new PDO(...$connArgs); var_dump($pdo->query('select 1')); $pdo = null; sleep(15); // kill the DB connection here //system('sudo systemctl restart postgresql-12'); //system('net stop postgresql-x64-12 && net start postgresql-x64-12'); $pdo = new PDO(...$connArgs); var_dump($pdo->query('select 1')); // should not throw but throws Expected result: ---------------- outputs 1 two times Actual result: -------------- outputs 1 then throws an exception -- Edit bug report at https://bugs.php.net/bug.php?id=78982&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=78982&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=78982&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=78982&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=78982&r=needscript Try newer version: https://bugs.php.net/fix.php?id=78982&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=78982&r=support Expected behavior: https://bugs.php.net/fix.php?id=78982&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=78982&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=78982&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=78982&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=78982&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=78982&r=dst IIS Stability: https://bugs.php.net/fix.php?id=78982&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=78982&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=78982&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=78982&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=78982&r=mysqlcfg

« previous php.bugs (#224363) next »