Bug #78980 [NEW]: pgsqlGetNotify() overlooks dead connection
| From: | kentaro at ranvis dot com | Date: | Tue, 17 Dec 2019 17:21:44 +0000 |
| Subject: | Bug #78980 [NEW]: pgsqlGetNotify() overlooks dead connection | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-224360@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:pgsqlGetNotify() overlooks dead connection
Description:
------------
pgsqlGetNotify() doesn't check the result of PQconsumeInput(),
which returns 0 on error.
If a caller is pooling by calling pgsqlGetNotify(),
it will never have a chance to known when the connection is lost.
(will add a PR)
Test script:
---------------
<?php
$connArgs = ['pgsql:dbname=DB_NAME', 'USER', 'PASSWORD', [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
]];
$pdo = new PDO(...$connArgs);
$pdo->exec('listen "test-event"');
var_dump($pdo->pgsqlGetNotify(PDO::FETCH_NUM, 1000));
sleep(15); // kill the DB connection here
//system('sudo systemctl restart postgresql-12');
//system('net stop postgresql-x64-12 && net start postgresql-x64-12');
var_dump($pdo->pgsqlGetNotify(PDO::FETCH_NUM, 1000)); // should throw
but doesn't
var_dump($pdo->query('select 1')); // throws
Expected result:
----------------
throws on $pdo->pgsqlGetNotify()
Actual result:
--------------
throws after $pdo->pgsqlGetNotify(), on $pdo->query('select 1')
--
Edit bug report at https://bugs.php.net/bug.php?id=78980&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=78980&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78980&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78980&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78980&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78980&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78980&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78980&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78980&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78980&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78980&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78980&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=78980&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78980&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78980&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78980&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78980&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78980&r=mysqlcfg