php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53287 PDO 5 Byte write to a broken pipe when forked
Submitted: 2010-11-10 03:21 UTC Modified: 2012-03-06 01:17 UTC
Votes:3
Avg. Score:4.0 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:1 (33.3%)
From: bryan dot tong at gigenet dot com Assigned: mysql (profile)
Status: Not a bug Package: PDO related
PHP Version: 5.3SVN-2010-11-10 (snap) OS: CentOS 5.5 x86-64
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: bryan dot tong at gigenet dot com
New email:
PHP Version: OS:

 

 [2010-11-10 03:21 UTC] bryan dot tong at gigenet dot com
Description:
------------
When switching from PHP 5.1.6 to PHP 5.3.3 the following notice has begun to show up in our scripts.

PDO::__construct(): send of 5 bytes failed with errno=32 Broken pipe

We are running a daemon and the forked children throw this error on the PDO construct that is used to refresh the class.

The error changes depending on whether a persistent connection is set or not.

When persistent is on the above error is produced. Without persistent connection applied the error is thrown when the class is destructed.

Example: $pdo = null;
send of 5 bytes failed with errno=32 Broken pipe

We have confirmed this to be apparent in PHP 5.3.3 and the trunk build. I was unable to test on 5.2, but I was able to confirm this bug does not occur on 5.1.6

I have tried wrapping ob functions around the calls in case the broken pipe happened to be stdout but I think it is the mysql socket that is in question. On that same note, switching mysql to connect via tcp did not help.

From searching I found a site that threw this error but no discussions of it.

Let me know any additional information that is needed.

Test script:
---------------
// without persistance
public static function shutdown(){
	$base = Base::getBase();
	$base->db = null;
	self::$base = false;
}

// with persistance
$this->pdo = new PDO(
	$dsn,
	$user,
	$pass,
	array(
		PDO::ATTR_ERRMODE	=>	PDO::ERRMODE_EXCEPTION,
		PDO::ATTR_PERSISTENT=>	true
	)
);

Expected result:
----------------
The PDO class should startup quietly when persistent connections are enabled and destruct quietly when persistent connections are disabled.

Actual result:
--------------
PDO::__construct(): send of 5 bytes failed with errno=32 Broken pipe with persistent connections.

Base::shutdown(): send of 5 bytes failed with errno=32 Broken pipe without persistent connections.

I believe this problem is only related to forked processes. I have confirmed the standard page serving to not throw this.





Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-10 04:11 UTC] aharvey@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: mysql
 [2010-11-26 13:19 UTC] johannes@php.net
-Status: Assigned +Status: Feedback
 [2010-11-26 13:19 UTC] johannes@php.net
The description mentions forking, the sample code not. Please provide a complete script showing the issue.
 [2010-12-05 21:23 UTC] seza at paradoxal dot org
I have the same error message with php.5.3.3 (send of 5 bytes failed with errno=32 Broken pipe) but in a 
different context more simply to reproduce :

I have a simple website (no fork or stuff like that). It make persistent connection with pdo to mysql 
(mysqlnd). The errors are raised when the mysql is server is restarted.

When mysql server is off error message are mysql server is gone away. No problem with that but once the 
mysql server is restarted and during 15 minutes I have sometimes this error message (send of 5 bytes 
failed with errno=32 Broken pipe). 
Certainly a reuse of a cached connection to mysql before it was restarted.

PS : I use mysql_sock connection (mysql:unix_socket=/var/run/mysqld/mysqld.sock)
 [2011-01-31 10:27 UTC] uw@php.net
This does not smell like an error rather more like mysqlnd being more verbose. No bug, a feature, I'd say.
 [2011-01-31 10:42 UTC] bryan dot tong at gigenet dot com
-Status: Feedback +Status: Assigned
 [2011-01-31 10:42 UTC] bryan dot tong at gigenet dot com
Though it can really make parsing the output a pain when there are multiple versions of mysqlnd floating about.
 [2012-03-06 01:17 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 [2012-03-06 01:17 UTC] johannes@php.net
-Status: Assigned +Status: Not a bug
 [2013-09-20 03:25 UTC] bryan at esited dot com
Hello,

I wanted to note that a common mysql configuration error will cause this issue.

Try changing the following.

wait_timeout=60
to
wait_timeout=3600

This is located in the /etc/mysql/my.cnf

Basically the wait_timeout value should equal that of client_max_read_timeout in 
NGINX.

Hopefully this will help someone else correct the issue.

Thanks
 [2016-02-15 11:17 UTC] dragomir dot enachi dot qs at gmail dot com
while using php7, restarting mysql service brings the error
disabling mysql persistent connections fixes the problem
 [2018-11-12 12:47 UTC] jferrer at data-solutions dot com
Not a bug...

I have only this problem with PHP.
I'm connecting to the same database with Java and Python and doing the same kind of operations...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 10:01:26 2024 UTC