From: chris dot noden at monstermob dot com
Operating system: Redhat AS 2.1
PHP version: 4.3.3
PHP Bug Type: MySQL related
Bug description: Lost connection to MySQL server during query
Description:
------------
MySQL version 4.0.13 running on a different server on the LAN using
pconnect:
After using a pcntl_fork() the child thread suffers from the "2013 : Lost
connection to MySQL server" error above.
I can continue to use the MySQL connection without connecting again
implying that the connection has miraculously re-established itself!
The error can occur at any stage in a query, (eg during submission or
reading the results of the query).
The error usually manifests itself when the query returns no results. The
error comes from the parent process!!
I have tried all sorts of workarounds, to no avail.
Reproduce code:
---------------
do {
$sql = "SELECT stuff FROM db WHERE a=b";
$qryID = mysql_query($sql,$Link_ID
while (mysql_fetch_array($qryID)) {
// Fork off a child
$is_parent = pcntl_fork();
if ($is_parent > 0) {
// I am the child - do some stuff
exit;
} else {
// I am the parent do some stuff
} // end if/else
sleep(1);
} while (condition);
Expected result:
----------------
Normal database flow.
Actual result:
--------------
Error 2013 - Lost connection to MySQL server during query
--
Edit bug report at http://bugs.php.net/?id=26490&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26490&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26490&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=26490&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=26490&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=26490&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=26490&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=26490&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=26490&r=support
Expected behavior: http://bugs.php.net/fix.php?id=26490&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=26490&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=26490&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=26490&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26490&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=26490&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=26490&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=26490&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26490&r=float