#26490 [Com]: Lost connection to MySQL server during query
| From: | gmartine at adinet dot com dot uy | Date: | Tue, 13 Jul 2004 19:25:03 +0000 |
| Subject: | #26490 [Com]: Lost connection to MySQL server during query | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-62162@lists.php.net to get a copy of this message | ||
ID: 26490
Comment by: gmartine at adinet dot com dot uy
Reported By: chris dot noden at monstermob dot com
Status: Verified
Bug Type: MySQL related
Operating System: *
PHP Version: 4CVS, 5CVS (2004-03-13)
New Comment:
Hi,
I have this very same error using "php 4.3.7" / "mysql 4.0.20a" under
windows 2000.
Regards.
Previous Comments:
------------------------------------------------------------------------
[2004-06-22 23:30:25] phpbug at nathandial dot com
I've got the same bug on gentoo. PHP 4.3.6, mysql 4.0.18
------------------------------------------------------------------------
[2004-06-20 20:22:08] theseer@php.net
I cannot speak for chris but at least we are running Redhat/Fedora
Systems using MySQL rpms from mysql.com.
I will check the workarounds mentioned on the redhat page and report
back.
------------------------------------------------------------------------
[2004-06-11 00:23:42] Ryan dot Springer at billingconcepts dot com
Is everyone who is effected by this bug running Red Hat? If so, this
may be a libc problem. See:
http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=75128
------------------------------------------------------------------------
[2004-03-11 11:39:40] theseer@php.net
This happens on the following versions:
php 4.3.3, 4.3.4, 4.3.5RC3
with bundled or external mysql client code
with shared or buildin
MySQL Server Version here is 4.0.18
The MySQL Log shows this row on a 'connection lost' error:
Aborted connection 2048 to db: [....] (Got an error reading
communication packets)
------------------------------------------------------------------------
[2004-03-11 11:35:27] theseer@php.net
Since i just stumbled across the very same problem, i wrote a small (?)
testcode to check it.
It seems like using pconnect in favor of a 'normal' connect fixes the
problem for the testcode, while it does not for my reallife
application.
The code assumes a database with at least 100 rows.
Structure as follows:
CREATE TABLE debug2 (
ID int(11) NOT NULL auto_increment,
CODE varchar(10) NOT NULL default '',
PRIMARY KEY (ID),
) TYPE=MyISAM
This is the testcode, run it from cli ;)
<?php
function do_something($ppid,$data) {
$db=mysql_connect('db.local.dev','dev','dev');
echo mysql_error();
mysql_selectdb('fpostv4',$db);
echo mysql_error();
foreach ($data as $row) {
$sql="update debug2 set CODE='1' where
ID='{$row['ID']}'";
echo "[$ppid] $sql\n";
$rc=mysql_query($sql);
echo mysql_error();
}
}
$db=mysql_connect('db.local.dev','dev','dev');
mysql_selectdb('fpostv4',$db);
echo mysql_error();
$rc=mysql_query('update debug2 set code=""');
echo mysql_error();
$rc=mysql_query('select * from debug2');
echo mysql_error();
for ($t=0; $t<10; $t++) {
$pid = pcntl_fork();
if ( $pid == -1 ) {
die('Error during fork() - halting');
} elseif ( $pid == 0 ) {
$ppid=getmypid();
mysql_data_seek($rc,$t*10);
echo mysql_error();
for ($x=0; $x<10; $x++) {
$data[]=mysql_fetch_assoc($rc);
}
do_something($ppid,$data);
die();
} else {
$pidlist[]=$pid;
$sendPos += $perThread;
}
}
// wait for them to finish...
while (count($pidlist)) {
foreach ($pidlist as $key => $ppid) {
$tmp=pcntl_waitpid($ppid, $temp, WNOHANG);
if ($tmp!=0 ) {
unset($pidlist[$key]);
}
}
sleep(2);
}
?>
You may have to run the code multiple times to actually see the
problem. The "Lost connection" error doesn't occur on a fixed rate or
value. You may be 'lucky' and don't hit it at all in a run..
Feel free to contact me in irc ( freenode / ircnet )
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/26490
--
Edit this bug report at http://bugs.php.net/?id=26490&edit=1