Bug #80412 [Opn]: PHP-FPM : PDO / Broken Pipe when DBMS ends the connection
| From: | daverandom@php.net | Date: | Tue, 24 Nov 2020 23:06:36 +0000 |
| Subject: | Bug #80412 [Opn]: PHP-FPM : PDO / Broken Pipe when DBMS ends the connection | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-230595@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80412&edit=1
ID: 80412
Updated by: daverandom@php.net
Reported by: heavy-traffic-website at yopmail dot com
Summary: PHP-FPM : PDO / Broken Pipe when DBMS ends the
connection
Status: Open
Type: Bug
Package: PDO Core
Operating System: Debian 11
PHP Version: 7.4.12
Block user comment: N
Private report: N
New Comment:
Note also that there is no implied re-connect on remote connection drop in any PHP-RDBMS drivers
(afaik). It is generally assumed that reconnection would be a thing that should be dealt with in
userland, as there is no universal strategy for interval, back-off or max retry count.
Previous Comments:
------------------------------------------------------------------------
[2020-11-24 23:03:25] daverandom@php.net
Note that this would be per-driver behaviour, specific to the RDBMS being used rather than a generic
PDO problem. Any further information on the RDBMS system/version affected would be useful -
obviously the DSN used with PDO indicates that MySQL is affected by this.
------------------------------------------------------------------------
[2020-11-24 23:00:16] heavy-traffic-website at yopmail dot com
Description:
------------
Related to this very old bug reported 10 years ago
=> https://bugs.php.net/bug.php?id=53287
(johannes@php.net) was wrong - the bug still exists and no one fixed it.
--> Please consider the bug onto the PHP side, not the DBMS side.
------------------------
new PDO("mysql:host=127.0.0.1;dbname=XXX", "XXX", "XXX", [
PDO::ATTR_PERSISTENT => true ]);
PHP-FPM have threads with broken persistent connections and SHOULD try to reconnect a new one
connection rather than CRASHING an exception in the case where send of 5 bytes failed with errno=32
Broken pipe appens in __construct.
Test script:
---------------
With php7.4-fpm, i have some threads and when i have a wide blank time between DBMS and PHP,
probably the timeout of the DBMS break the pipe (default: 8h), however PHP/PDO don't care and
throw an exception instead of making a new one connection, inside each thread alive.
Currently, I have to try{ new PDO() }catch(){ new PDO() } to be working without error, it sucks !
Expected result:
----------------
The PDO side CAN be patched, so this is a bug. It is expected that PDO will try to reconnect
silently if the case described appears, before lauching any exception. And if any exception has to
be launched, it will certainly will not be these one but the new connection exception.
Actual result:
--------------
Catched Exception :
PDO::__construct(): send of 5 bytes failed with errno=32 Broken pipe
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80412&edit=1