|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2020-11-24 23:00 UTC] 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 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 18:00:01 2025 UTC |
Thank you for your review. The code PDO::__contruct() is very explicit : I want a persistent connection. And this line works until the pipe exists. Maybe not everybody use HAproxy between Galera Cluster and PHP-FPM but, the code to keep it working without error is really poor : try{ new PDO() }catch(){ new PDO() } Please don't justify this is normal, when the pipe broke whatever the reason is : PHP/PDO should DETECT the broken PIPE and treat the __construct like no one persistent connection exists yet inside each thead. We are on the ends of 2020, it has to think logic and serve the langage, not saying like 10 year ago : it is still a feature.Some precisons : ini_set("error_reporting", (string) E_ALL); ini_set("display_errors", "On"); ini_set("display_startup_errors", "On"); ini_set("track_errors", "On"); set_exception_handler("my_exception"); set_error_handler("my_error"); [ERROR HANDLER] errno: int(8) errstr: string(68) "PDO::__construct(): send of 5 bytes failed with errno=32 Broken pipe" errfile: string(31) "/var/www/XXX/Database.class.php" errline: int(28) line 27 --> $db = new PDO("mysql:host=127.0.0.1;dbname=XXX", "XXX", "XXX", line 28 --> PDO::ATTR_PERSISTENT => true, line 29 --> PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);Actual result: -------------- string(26) "<BEFORE new PDO(), loop 1>" string(34) "------------[ ERROR ]-------------" string(79) "-- errstr: PDO::__construct(): send of 5 bytes failed with errno=32 Broken pipe" string(34) "----------------------------------" string(25) "<AFTER new PDO(), loop 1>" object(PDO)#2 (0) { } int(1) string(26) "<BEFORE new PDO(), loop 2>" string(25) "<AFTER new PDO(), loop 2>" object(PDO)#3 (0) { } int(1) string(26) "<BEFORE new PDO(), loop 3>" string(25) "<AFTER new PDO(), loop 3>" object(PDO)#2 (0) { } int(1) string(26) "<BEFORE new PDO(), loop 4>" string(25) "<AFTER new PDO(), loop 4>" object(PDO)#3 (0) { } int(1) string(26) "<BEFORE new PDO(), loop 5>" string(25) "<AFTER new PDO(), loop 5>" object(PDO)#2 (0) { } int(1) string(26) "<BEFORE new PDO(), loop 6>" string(25) "<AFTER new PDO(), loop 6>" object(PDO)#3 (0) { } int(1)