#26490 [Com]: Lost connection to MySQL server during query

2007-06-15 Thread angel at support-24 dot com
 ID:   26490
 Comment by:   angel at support-24 dot com
 Reported By:  chris dot noden at monstermob dot com
 Status:   No Feedback
 Bug Type: MySQL related
 Operating System: *
 PHP Version:  4CVS, 5CVS (2004-03-13)
 New Comment:

I have this issue only while crawling something. 
For example I have 50 000 curl requests to a page. I crawl the page,
gather info and store it in a database, only if the page contains what
I'm looking for.

I have noticed that in about every 50 queries the mysql insert query
crashes with this error: Lost connection to MySQL server during query

System is: Windows XP, Apache 2.2 MySQL 5.0


Previous Comments:


[2007-05-23 06:38:50] david at ols dot es

I have the same problem with php 4.4.4, from time to time
both pconnect and connect fail with error  Lost connection to MySQL
server during query, but only when using a mysql server on a remote
machine, never when using local sockets



[2006-12-15 15:46:37] 18sanny at azet dot sk

If this image is hard to read, reload the page.



[2006-08-10 21:52:54] mcote at voyagesconstellation dot com

Same problem, sometimes!  But if we keep trying we usually get result
in 2-3 tries, this code works to keep trying without hanging forever!

$result = FALSE;
$counter = 0;
while($result==FALSE)
{
  $res = mysql_query($waitquery);
  $result = mysql_fetch_assoc($res);
  $counter++;
  error_log(error happened! - mysql Connection was lost!! 
try#$counter);
  if ($counter==5)//prevents major major hang! ;-)
break;
}



[2005-04-14 19:16:15] Andreas dot Oesterhelt at InTradeSys dot com

After further thinking at least my test case
and Chris' original case are non-bugs:

The child inherits the parent's open connection.

When it dies, all its open files, including the
(unused) inherited connection are closed.

If the parent subsequently calls mysql_query() on
that closed connection, a new one will be opened.
But if the child termination happens while the parent
is executing a query, the parent indeed loses its
connection during its query.

Sorry for wasting your time,
--Andreas

PS: Fork logic in testcase script was flawed, too.
Should have been: if (!$is_child).



[2005-04-14 16:38:01] Andreas dot Oesterhelt at InTradeSys dot com

As requested by theseer @php.net I'm adding a test
case that steadily reproduces the problem for me.

Both on a Single CPU Pentium 4, Linux 2.4.29, PHP
4.3.10, MySQL 4.1.10, libc 2.2.5 machine, as well
as on a four CPU Ultra Sparc, Linux 2.4.27, PHP
4.3.10, MySQL 4.1.10a, libc 2.3.2 box I get the same 
results.

The proposed workaround doesn't change that behaviour.

The example code assumes there is a database testcasedb,
to which a user testcaseuser on localhost using testcasepw
has access. It needs to contain a table like this, although
the table type really doesn't seem to matter:

CREATE TABLE `testtable` (`row1` varchar(40) NOT NULL 
default '', `tstamp` timestamp NULL default NULL)  DEFAULT 
CHARSET=latin1 ;

?php

$dbres = mysql_connect('localhost', 'testcaseuser', 'testcasepw');

$parent_sql = INSERT INTO testcasedb.testtable VALUES ('some test',
now());
$child_sql  = DELETE FROM testcasedb.testtable WHERE row1 = 'some
test';

do
{
for ($i = 1; $i = 20; $i++)
{
print(Parent query starts\n);

if (!mysql_query($parent_sql, $dbres))
{
print(Parent Mysql Error:  . mysql_error($dbres) . 
\n);
}
}

$is_child = pcntl_fork();

if ($is_child  0)
{
print(Child connection and query start\n);
$dbres = mysql_connect('localhost', 'testcaseuser', 
'testcasepw',
true);

if (!mysql_query($child_sql, $dbres))
{
print(Child Mysql Error:  . mysql_error($dbres) . 
\n);
}
exit;

}

print(Parent next iteration\n);

} while (true); 

?

Basically the parent process loops forever, spawning
children that each open a connection of their own, do
a query and then die.

You'll see that the parent will report Lost connections
soon, although the children are doing their best not 
to reuse the parent's connection.

Hope this helps to deeper look into the issue.

Thanks for listening,
--Andreas



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 

#26490 [Com]: Lost connection to MySQL server during query

2007-05-23 Thread david at ols dot es
 ID:   26490
 Comment by:   david at ols dot es
 Reported By:  chris dot noden at monstermob dot com
 Status:   No Feedback
 Bug Type: MySQL related
 Operating System: *
 PHP Version:  4CVS, 5CVS (2004-03-13)
 New Comment:

I have the same problem with php 4.4.4, from time to time
both pconnect and connect fail with error  Lost connection to MySQL
server during query, but only when using a mysql server on a remote
machine, never when using local sockets


Previous Comments:


[2006-12-15 15:46:37] 18sanny at azet dot sk

If this image is hard to read, reload the page.



[2006-08-10 21:52:54] mcote at voyagesconstellation dot com

Same problem, sometimes!  But if we keep trying we usually get result
in 2-3 tries, this code works to keep trying without hanging forever!

$result = FALSE;
$counter = 0;
while($result==FALSE)
{
  $res = mysql_query($waitquery);
  $result = mysql_fetch_assoc($res);
  $counter++;
  error_log(error happened! - mysql Connection was lost!! 
try#$counter);
  if ($counter==5)//prevents major major hang! ;-)
break;
}



[2005-04-14 19:16:15] Andreas dot Oesterhelt at InTradeSys dot com

After further thinking at least my test case
and Chris' original case are non-bugs:

The child inherits the parent's open connection.

When it dies, all its open files, including the
(unused) inherited connection are closed.

If the parent subsequently calls mysql_query() on
that closed connection, a new one will be opened.
But if the child termination happens while the parent
is executing a query, the parent indeed loses its
connection during its query.

Sorry for wasting your time,
--Andreas

PS: Fork logic in testcase script was flawed, too.
Should have been: if (!$is_child).



[2005-04-14 16:38:01] Andreas dot Oesterhelt at InTradeSys dot com

As requested by theseer @php.net I'm adding a test
case that steadily reproduces the problem for me.

Both on a Single CPU Pentium 4, Linux 2.4.29, PHP
4.3.10, MySQL 4.1.10, libc 2.2.5 machine, as well
as on a four CPU Ultra Sparc, Linux 2.4.27, PHP
4.3.10, MySQL 4.1.10a, libc 2.3.2 box I get the same 
results.

The proposed workaround doesn't change that behaviour.

The example code assumes there is a database testcasedb,
to which a user testcaseuser on localhost using testcasepw
has access. It needs to contain a table like this, although
the table type really doesn't seem to matter:

CREATE TABLE `testtable` (`row1` varchar(40) NOT NULL 
default '', `tstamp` timestamp NULL default NULL)  DEFAULT 
CHARSET=latin1 ;

?php

$dbres = mysql_connect('localhost', 'testcaseuser', 'testcasepw');

$parent_sql = INSERT INTO testcasedb.testtable VALUES ('some test',
now());
$child_sql  = DELETE FROM testcasedb.testtable WHERE row1 = 'some
test';

do
{
for ($i = 1; $i = 20; $i++)
{
print(Parent query starts\n);

if (!mysql_query($parent_sql, $dbres))
{
print(Parent Mysql Error:  . mysql_error($dbres) . 
\n);
}
}

$is_child = pcntl_fork();

if ($is_child  0)
{
print(Child connection and query start\n);
$dbres = mysql_connect('localhost', 'testcaseuser', 
'testcasepw',
true);

if (!mysql_query($child_sql, $dbres))
{
print(Child Mysql Error:  . mysql_error($dbres) . 
\n);
}
exit;

}

print(Parent next iteration\n);

} while (true); 

?

Basically the parent process loops forever, spawning
children that each open a connection of their own, do
a query and then die.

You'll see that the parent will report Lost connections
soon, although the children are doing their best not 
to reuse the parent's connection.

Hope this helps to deeper look into the issue.

Thanks for listening,
--Andreas



[2004-10-01 01:00:02] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to Open.



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=26490edit=1


#26490 [Com]: Lost connection to MySQL server during query

2006-12-15 Thread 18sanny at azet dot sk
 ID:   26490
 Comment by:   18sanny at azet dot sk
 Reported By:  chris dot noden at monstermob dot com
 Status:   No Feedback
 Bug Type: MySQL related
 Operating System: *
 PHP Version:  4CVS, 5CVS (2004-03-13)
 New Comment:

If this image is hard to read, reload the page.


Previous Comments:


[2006-08-10 21:52:54] mcote at voyagesconstellation dot com

Same problem, sometimes!  But if we keep trying we usually get result
in 2-3 tries, this code works to keep trying without hanging forever!

$result = FALSE;
$counter = 0;
while($result==FALSE)
{
  $res = mysql_query($waitquery);
  $result = mysql_fetch_assoc($res);
  $counter++;
  error_log(error happened! - mysql Connection was lost!! 
try#$counter);
  if ($counter==5)//prevents major major hang! ;-)
break;
}



[2005-04-14 19:16:15] Andreas dot Oesterhelt at InTradeSys dot com

After further thinking at least my test case
and Chris' original case are non-bugs:

The child inherits the parent's open connection.

When it dies, all its open files, including the
(unused) inherited connection are closed.

If the parent subsequently calls mysql_query() on
that closed connection, a new one will be opened.
But if the child termination happens while the parent
is executing a query, the parent indeed loses its
connection during its query.

Sorry for wasting your time,
--Andreas

PS: Fork logic in testcase script was flawed, too.
Should have been: if (!$is_child).



[2005-04-14 16:38:01] Andreas dot Oesterhelt at InTradeSys dot com

As requested by theseer @php.net I'm adding a test
case that steadily reproduces the problem for me.

Both on a Single CPU Pentium 4, Linux 2.4.29, PHP
4.3.10, MySQL 4.1.10, libc 2.2.5 machine, as well
as on a four CPU Ultra Sparc, Linux 2.4.27, PHP
4.3.10, MySQL 4.1.10a, libc 2.3.2 box I get the same 
results.

The proposed workaround doesn't change that behaviour.

The example code assumes there is a database testcasedb,
to which a user testcaseuser on localhost using testcasepw
has access. It needs to contain a table like this, although
the table type really doesn't seem to matter:

CREATE TABLE `testtable` (`row1` varchar(40) NOT NULL 
default '', `tstamp` timestamp NULL default NULL)  DEFAULT 
CHARSET=latin1 ;

?php

$dbres = mysql_connect('localhost', 'testcaseuser', 'testcasepw');

$parent_sql = INSERT INTO testcasedb.testtable VALUES ('some test',
now());
$child_sql  = DELETE FROM testcasedb.testtable WHERE row1 = 'some
test';

do
{
for ($i = 1; $i = 20; $i++)
{
print(Parent query starts\n);

if (!mysql_query($parent_sql, $dbres))
{
print(Parent Mysql Error:  . mysql_error($dbres) . 
\n);
}
}

$is_child = pcntl_fork();

if ($is_child  0)
{
print(Child connection and query start\n);
$dbres = mysql_connect('localhost', 'testcaseuser', 
'testcasepw',
true);

if (!mysql_query($child_sql, $dbres))
{
print(Child Mysql Error:  . mysql_error($dbres) . 
\n);
}
exit;

}

print(Parent next iteration\n);

} while (true); 

?

Basically the parent process loops forever, spawning
children that each open a connection of their own, do
a query and then die.

You'll see that the parent will report Lost connections
soon, although the children are doing their best not 
to reuse the parent's connection.

Hope this helps to deeper look into the issue.

Thanks for listening,
--Andreas



[2004-10-01 01:00:02] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to Open.



[2004-09-23 12:05:07] [EMAIL PROTECTED]

Due to people claiming the workaround doesn't fix their problems, the
bug is reopened.

Please provide detailed feedback on how to reproduce the problem.



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=26490edit=1


#26490 [Com]: Lost connection to MySQL server during query

2006-12-07 Thread claudelfino at hotmail dot com
 ID:   26490
 Comment by:   claudelfino at hotmail dot com
 Reported By:  chris dot noden at monstermob dot com
 Status:   No Feedback
 Bug Type: MySQL related
 Operating System: *
 PHP Version:  4CVS, 5CVS (2004-03-13)
 New Comment:

If this image is hard to read, reload the page


Previous Comments:


[2006-08-10 21:52:54] mcote at voyagesconstellation dot com

Same problem, sometimes!  But if we keep trying we usually get result
in 2-3 tries, this code works to keep trying without hanging forever!

$result = FALSE;
$counter = 0;
while($result==FALSE)
{
  $res = mysql_query($waitquery);
  $result = mysql_fetch_assoc($res);
  $counter++;
  error_log(error happened! - mysql Connection was lost!! 
try#$counter);
  if ($counter==5)//prevents major major hang! ;-)
break;
}



[2005-04-14 19:16:15] Andreas dot Oesterhelt at InTradeSys dot com

After further thinking at least my test case
and Chris' original case are non-bugs:

The child inherits the parent's open connection.

When it dies, all its open files, including the
(unused) inherited connection are closed.

If the parent subsequently calls mysql_query() on
that closed connection, a new one will be opened.
But if the child termination happens while the parent
is executing a query, the parent indeed loses its
connection during its query.

Sorry for wasting your time,
--Andreas

PS: Fork logic in testcase script was flawed, too.
Should have been: if (!$is_child).



[2005-04-14 16:38:01] Andreas dot Oesterhelt at InTradeSys dot com

As requested by theseer @php.net I'm adding a test
case that steadily reproduces the problem for me.

Both on a Single CPU Pentium 4, Linux 2.4.29, PHP
4.3.10, MySQL 4.1.10, libc 2.2.5 machine, as well
as on a four CPU Ultra Sparc, Linux 2.4.27, PHP
4.3.10, MySQL 4.1.10a, libc 2.3.2 box I get the same 
results.

The proposed workaround doesn't change that behaviour.

The example code assumes there is a database testcasedb,
to which a user testcaseuser on localhost using testcasepw
has access. It needs to contain a table like this, although
the table type really doesn't seem to matter:

CREATE TABLE `testtable` (`row1` varchar(40) NOT NULL 
default '', `tstamp` timestamp NULL default NULL)  DEFAULT 
CHARSET=latin1 ;

?php

$dbres = mysql_connect('localhost', 'testcaseuser', 'testcasepw');

$parent_sql = INSERT INTO testcasedb.testtable VALUES ('some test',
now());
$child_sql  = DELETE FROM testcasedb.testtable WHERE row1 = 'some
test';

do
{
for ($i = 1; $i = 20; $i++)
{
print(Parent query starts\n);

if (!mysql_query($parent_sql, $dbres))
{
print(Parent Mysql Error:  . mysql_error($dbres) . 
\n);
}
}

$is_child = pcntl_fork();

if ($is_child  0)
{
print(Child connection and query start\n);
$dbres = mysql_connect('localhost', 'testcaseuser', 
'testcasepw',
true);

if (!mysql_query($child_sql, $dbres))
{
print(Child Mysql Error:  . mysql_error($dbres) . 
\n);
}
exit;

}

print(Parent next iteration\n);

} while (true); 

?

Basically the parent process loops forever, spawning
children that each open a connection of their own, do
a query and then die.

You'll see that the parent will report Lost connections
soon, although the children are doing their best not 
to reuse the parent's connection.

Hope this helps to deeper look into the issue.

Thanks for listening,
--Andreas



[2004-10-01 01:00:02] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to Open.



[2004-09-23 12:05:07] [EMAIL PROTECTED]

Due to people claiming the workaround doesn't fix their problems, the
bug is reopened.

Please provide detailed feedback on how to reproduce the problem.



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=26490edit=1


#26490 [Com]: Lost connection to MySQL server during query

2006-08-10 Thread mcote at voyagesconstellation dot com
 ID:   26490
 Comment by:   mcote at voyagesconstellation dot com
 Reported By:  chris dot noden at monstermob dot com
 Status:   No Feedback
 Bug Type: MySQL related
 Operating System: *
 PHP Version:  4CVS, 5CVS (2004-03-13)
 New Comment:

Same problem, sometimes!  But if we keep trying we usually get result
in 2-3 tries, this code works to keep trying without hanging forever!

$result = FALSE;
$counter = 0;
while($result==FALSE)
{
  $res = mysql_query($waitquery);
  $result = mysql_fetch_assoc($res);
  $counter++;
  error_log(error happened! - mysql Connection was lost!! 
try#$counter);
  if ($counter==5)//prevents major major hang! ;-)
break;
}


Previous Comments:


[2005-04-14 19:16:15] Andreas dot Oesterhelt at InTradeSys dot com

After further thinking at least my test case
and Chris' original case are non-bugs:

The child inherits the parent's open connection.

When it dies, all its open files, including the
(unused) inherited connection are closed.

If the parent subsequently calls mysql_query() on
that closed connection, a new one will be opened.
But if the child termination happens while the parent
is executing a query, the parent indeed loses its
connection during its query.

Sorry for wasting your time,
--Andreas

PS: Fork logic in testcase script was flawed, too.
Should have been: if (!$is_child).



[2005-04-14 16:38:01] Andreas dot Oesterhelt at InTradeSys dot com

As requested by theseer @php.net I'm adding a test
case that steadily reproduces the problem for me.

Both on a Single CPU Pentium 4, Linux 2.4.29, PHP
4.3.10, MySQL 4.1.10, libc 2.2.5 machine, as well
as on a four CPU Ultra Sparc, Linux 2.4.27, PHP
4.3.10, MySQL 4.1.10a, libc 2.3.2 box I get the same 
results.

The proposed workaround doesn't change that behaviour.

The example code assumes there is a database testcasedb,
to which a user testcaseuser on localhost using testcasepw
has access. It needs to contain a table like this, although
the table type really doesn't seem to matter:

CREATE TABLE `testtable` (`row1` varchar(40) NOT NULL 
default '', `tstamp` timestamp NULL default NULL)  DEFAULT 
CHARSET=latin1 ;

?php

$dbres = mysql_connect('localhost', 'testcaseuser', 'testcasepw');

$parent_sql = INSERT INTO testcasedb.testtable VALUES ('some test',
now());
$child_sql  = DELETE FROM testcasedb.testtable WHERE row1 = 'some
test';

do
{
for ($i = 1; $i = 20; $i++)
{
print(Parent query starts\n);

if (!mysql_query($parent_sql, $dbres))
{
print(Parent Mysql Error:  . mysql_error($dbres) . 
\n);
}
}

$is_child = pcntl_fork();

if ($is_child  0)
{
print(Child connection and query start\n);
$dbres = mysql_connect('localhost', 'testcaseuser', 
'testcasepw',
true);

if (!mysql_query($child_sql, $dbres))
{
print(Child Mysql Error:  . mysql_error($dbres) . 
\n);
}
exit;

}

print(Parent next iteration\n);

} while (true); 

?

Basically the parent process loops forever, spawning
children that each open a connection of their own, do
a query and then die.

You'll see that the parent will report Lost connections
soon, although the children are doing their best not 
to reuse the parent's connection.

Hope this helps to deeper look into the issue.

Thanks for listening,
--Andreas



[2004-10-01 01:00:02] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to Open.



[2004-09-23 12:05:07] [EMAIL PROTECTED]

Due to people claiming the workaround doesn't fix their problems, the
bug is reopened.

Please provide detailed feedback on how to reproduce the problem.



[2004-09-22 21:06:23] tru at gtwreck dot com

All you need to do is check out this query on google, and you can see
that a lot of sites have this issue while google is indexing them...
http://www.google.com/search?hl=enlr=ie=UTF-8q=%22Lost+connection+to+MySQL+server+during+query%22+mysql_connect



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 

#26490 [Com]: Lost connection to MySQL server during query

2005-04-14 Thread Andreas dot Oesterhelt at InTradeSys dot com
 ID:   26490
 Comment by:   Andreas dot Oesterhelt at InTradeSys dot com
 Reported By:  chris dot noden at monstermob dot com
 Status:   No Feedback
 Bug Type: MySQL related
 Operating System: *
 PHP Version:  4CVS, 5CVS (2004-03-13)
 New Comment:

As requested by theseer @php.net I'm adding a test
case that steadily reproduces the problem for me.

Both on a Single CPU Pentium 4, Linux 2.4.29, PHP
4.3.10, MySQL 4.1.10, libc 2.2.5 machine, as well
as on a four CPU Ultra Sparc, Linux 2.4.27, PHP
4.3.10, MySQL 4.1.10a, libc 2.3.2 box I get the same 
results.

The proposed workaround doesn't change that behaviour.

The example code assumes there is a database testcasedb,
to which a user testcaseuser on localhost using testcasepw
has access. It needs to contain a table like this, although
the table type really doesn't seem to matter:

CREATE TABLE `testtable` (`row1` varchar(40) NOT NULL 
default '', `tstamp` timestamp NULL default NULL)  DEFAULT 
CHARSET=latin1 ;

?php

$dbres = mysql_connect('localhost', 'testcaseuser', 'testcasepw');

$parent_sql = INSERT INTO testcasedb.testtable VALUES ('some test',
now());
$child_sql  = DELETE FROM testcasedb.testtable WHERE row1 = 'some
test';

do
{
for ($i = 1; $i = 20; $i++)
{
print(Parent query starts\n);

if (!mysql_query($parent_sql, $dbres))
{
print(Parent Mysql Error:  . mysql_error($dbres) . 
\n);
}
}

$is_child = pcntl_fork();

if ($is_child  0)
{
print(Child connection and query start\n);
$dbres = mysql_connect('localhost', 'testcaseuser', 
'testcasepw',
true);

if (!mysql_query($child_sql, $dbres))
{
print(Child Mysql Error:  . mysql_error($dbres) . 
\n);
}
exit;

}

print(Parent next iteration\n);

} while (true); 

?

Basically the parent process loops forever, spawning
children that each open a connection of their own, do
a query and then die.

You'll see that the parent will report Lost connections
soon, although the children are doing their best not 
to reuse the parent's connection.

Hope this helps to deeper look into the issue.

Thanks for listening,
--Andreas


Previous Comments:


[2004-10-01 01:00:02] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to Open.



[2004-09-23 12:05:07] [EMAIL PROTECTED]

Due to people claiming the workaround doesn't fix their problems, the
bug is reopened.

Please provide detailed feedback on how to reproduce the problem.



[2004-09-22 21:06:23] tru at gtwreck dot com

All you need to do is check out this query on google, and you can see
that a lot of sites have this issue while google is indexing them...
http://www.google.com/search?hl=enlr=ie=UTF-8q=%22Lost+connection+to+MySQL+server+during+query%22+mysql_connect



[2004-09-22 21:03:00] tommy at allstardirectories dot com

The suggested work-around does not work for me.  I'm still seeing
intermittent connection losses (About 5-10 per day).



[2004-08-12 19:20:53] [EMAIL PROTECTED]

This is not a bug at all but rather a problem created by the reuse of
connections within php:
The mysql_connect() command does NOT open a new connection by default.
So even if one calls mysql_connect() in the forked child, no new
conenction is opened. Adding the addtional parameter to force a new
connection fixes the problem right away.





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=26490edit=1


#26490 [Com]: Lost connection to MySQL server during query

2005-04-14 Thread Andreas dot Oesterhelt at InTradeSys dot com
 ID:   26490
 Comment by:   Andreas dot Oesterhelt at InTradeSys dot com
 Reported By:  chris dot noden at monstermob dot com
 Status:   No Feedback
 Bug Type: MySQL related
 Operating System: *
 PHP Version:  4CVS, 5CVS (2004-03-13)
 New Comment:

After further thinking at least my test case
and Chris' original case are non-bugs:

The child inherits the parent's open connection.

When it dies, all its open files, including the
(unused) inherited connection are closed.

If the parent subsequently calls mysql_query() on
that closed connection, a new one will be opened.
But if the child termination happens while the parent
is executing a query, the parent indeed loses its
connection during its query.

Sorry for wasting your time,
--Andreas

PS: Fork logic in testcase script was flawed, too.
Should have been: if (!$is_child).


Previous Comments:


[2005-04-14 16:38:01] Andreas dot Oesterhelt at InTradeSys dot com

As requested by theseer @php.net I'm adding a test
case that steadily reproduces the problem for me.

Both on a Single CPU Pentium 4, Linux 2.4.29, PHP
4.3.10, MySQL 4.1.10, libc 2.2.5 machine, as well
as on a four CPU Ultra Sparc, Linux 2.4.27, PHP
4.3.10, MySQL 4.1.10a, libc 2.3.2 box I get the same 
results.

The proposed workaround doesn't change that behaviour.

The example code assumes there is a database testcasedb,
to which a user testcaseuser on localhost using testcasepw
has access. It needs to contain a table like this, although
the table type really doesn't seem to matter:

CREATE TABLE `testtable` (`row1` varchar(40) NOT NULL 
default '', `tstamp` timestamp NULL default NULL)  DEFAULT 
CHARSET=latin1 ;

?php

$dbres = mysql_connect('localhost', 'testcaseuser', 'testcasepw');

$parent_sql = INSERT INTO testcasedb.testtable VALUES ('some test',
now());
$child_sql  = DELETE FROM testcasedb.testtable WHERE row1 = 'some
test';

do
{
for ($i = 1; $i = 20; $i++)
{
print(Parent query starts\n);

if (!mysql_query($parent_sql, $dbres))
{
print(Parent Mysql Error:  . mysql_error($dbres) . 
\n);
}
}

$is_child = pcntl_fork();

if ($is_child  0)
{
print(Child connection and query start\n);
$dbres = mysql_connect('localhost', 'testcaseuser', 
'testcasepw',
true);

if (!mysql_query($child_sql, $dbres))
{
print(Child Mysql Error:  . mysql_error($dbres) . 
\n);
}
exit;

}

print(Parent next iteration\n);

} while (true); 

?

Basically the parent process loops forever, spawning
children that each open a connection of their own, do
a query and then die.

You'll see that the parent will report Lost connections
soon, although the children are doing their best not 
to reuse the parent's connection.

Hope this helps to deeper look into the issue.

Thanks for listening,
--Andreas



[2004-10-01 01:00:02] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to Open.



[2004-09-23 12:05:07] [EMAIL PROTECTED]

Due to people claiming the workaround doesn't fix their problems, the
bug is reopened.

Please provide detailed feedback on how to reproduce the problem.



[2004-09-22 21:06:23] tru at gtwreck dot com

All you need to do is check out this query on google, and you can see
that a lot of sites have this issue while google is indexing them...
http://www.google.com/search?hl=enlr=ie=UTF-8q=%22Lost+connection+to+MySQL+server+during+query%22+mysql_connect



[2004-09-22 21:03:00] tommy at allstardirectories dot com

The suggested work-around does not work for me.  I'm still seeing
intermittent connection losses (About 5-10 per day).



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=26490edit=1


#26490 [Com]: Lost connection to MySQL server during query

2004-09-22 Thread tommy at allstardirectories dot com
 ID:   26490
 Comment by:   tommy at allstardirectories dot com
 Reported By:  chris dot noden at monstermob dot com
 Status:   Closed
 Bug Type: MySQL related
 Operating System: *
 PHP Version:  4CVS, 5CVS (2004-03-13)
 New Comment:

The suggested work-around does not work for me.  I'm still seeing
intermittent connection losses (About 5-10 per day).


Previous Comments:


[2004-08-12 19:20:53] [EMAIL PROTECTED]

This is not a bug at all but rather a problem created by the reuse of
connections within php:
The mysql_connect() command does NOT open a new connection by default.
So even if one calls mysql_connect() in the forked child, no new
conenction is opened. Adding the addtional parameter to force a new
connection fixes the problem right away.





[2004-08-10 17:11:12] christian at jul dot net

Happened for me on php 4.3.8 / mysql 4.0.20 / debian unstable

Seems like putting the db connection after the fork solved the problem.
Apparently the connection dies when the connecting process exits, but
should be kept alive as long as   there is living child processes.



[2004-08-03 07:27:29] adams at mars-project dot com

I also get this error, but its on an internal mysql server.

PHP 4.3.7
MySQL 4.0.18
FreeBSD 4.10

And just to note when i do get this error i get a php core dump as
well.



[2004-07-21 17:20:59] florian dot heigl at m4f dot net

I got the same error w/o using php - connecting via bin/mysql...

It only happens *sometimes* :)
ERROR 2013 at line 78: Lost connection to MySQL server during query


OS is Tru64 5.1B-4, MySQL 4.0.20



[2004-07-20 15:00:52] garak at studenti dot it

Same problem.
Connect to mysql server on LAN.
PHP 4.3.7
MySQL 4.0.20
Linux 2.4.19



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=26490edit=1


#26490 [Com]: Lost connection to MySQL server during query

2004-09-22 Thread tru at gtwreck dot com
 ID:   26490
 Comment by:   tru at gtwreck dot com
 Reported By:  chris dot noden at monstermob dot com
 Status:   Closed
 Bug Type: MySQL related
 Operating System: *
 PHP Version:  4CVS, 5CVS (2004-03-13)
 New Comment:

All you need to do is check out this query on google, and you can see
that a lot of sites have this issue while google is indexing them...
http://www.google.com/search?hl=enlr=ie=UTF-8q=%22Lost+connection+to+MySQL+server+during+query%22+mysql_connect


Previous Comments:


[2004-09-22 21:03:00] tommy at allstardirectories dot com

The suggested work-around does not work for me.  I'm still seeing
intermittent connection losses (About 5-10 per day).



[2004-08-12 19:20:53] [EMAIL PROTECTED]

This is not a bug at all but rather a problem created by the reuse of
connections within php:
The mysql_connect() command does NOT open a new connection by default.
So even if one calls mysql_connect() in the forked child, no new
conenction is opened. Adding the addtional parameter to force a new
connection fixes the problem right away.





[2004-08-10 17:11:12] christian at jul dot net

Happened for me on php 4.3.8 / mysql 4.0.20 / debian unstable

Seems like putting the db connection after the fork solved the problem.
Apparently the connection dies when the connecting process exits, but
should be kept alive as long as   there is living child processes.



[2004-08-03 07:27:29] adams at mars-project dot com

I also get this error, but its on an internal mysql server.

PHP 4.3.7
MySQL 4.0.18
FreeBSD 4.10

And just to note when i do get this error i get a php core dump as
well.



[2004-07-21 17:20:59] florian dot heigl at m4f dot net

I got the same error w/o using php - connecting via bin/mysql...

It only happens *sometimes* :)
ERROR 2013 at line 78: Lost connection to MySQL server during query


OS is Tru64 5.1B-4, MySQL 4.0.20



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=26490edit=1


#26490 [Com]: Lost connection to MySQL server during query

2004-08-10 Thread christian at jul dot net
 ID:   26490
 Comment by:   christian at jul dot net
 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:

Happened for me on php 4.3.8 / mysql 4.0.20 / debian unstable

Seems like putting the db connection after the fork solved the problem.
Apparently the connection dies when the connecting process exits, but
should be kept alive as long as   there is living child processes.


Previous Comments:


[2004-08-03 07:27:29] adams at mars-project dot com

I also get this error, but its on an internal mysql server.

PHP 4.3.7
MySQL 4.0.18
FreeBSD 4.10

And just to note when i do get this error i get a php core dump as
well.



[2004-07-21 17:20:59] florian dot heigl at m4f dot net

I got the same error w/o using php - connecting via bin/mysql...

It only happens *sometimes* :)
ERROR 2013 at line 78: Lost connection to MySQL server during query


OS is Tru64 5.1B-4, MySQL 4.0.20



[2004-07-20 15:00:52] garak at studenti dot it

Same problem.
Connect to mysql server on LAN.
PHP 4.3.7
MySQL 4.0.20
Linux 2.4.19



[2004-07-17 09:58:07] jdittmer at ppp0 dot net

Just wanted to say, that I see the very same error with php 4.3.8 and
postgres. (pconnect  connect) System is Debian/GNU Linux



[2004-07-16 19:51:09] genio at qwest dot net

I've been able to reproduce the error on OpenBSD using php5 and mysql5
alpha. I assumed the error occured due to the fact im using an alpha
release version of mysql, in my case it might not be a php bug because
Im able to reproduce a similar mysql error with a jsp servlet
connection



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=26490edit=1


#26490 [Com]: Lost connection to MySQL server during query

2004-08-02 Thread adams at mars-project dot com
 ID:   26490
 Comment by:   adams at mars-project dot com
 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:

I also get this error, but its on an internal mysql server.

PHP 4.3.7
MySQL 4.0.18
FreeBSD 4.10

And just to note when i do get this error i get a php core dump as
well.


Previous Comments:


[2004-07-21 17:20:59] florian dot heigl at m4f dot net

I got the same error w/o using php - connecting via bin/mysql...

It only happens *sometimes* :)
ERROR 2013 at line 78: Lost connection to MySQL server during query


OS is Tru64 5.1B-4, MySQL 4.0.20



[2004-07-20 15:00:52] garak at studenti dot it

Same problem.
Connect to mysql server on LAN.
PHP 4.3.7
MySQL 4.0.20
Linux 2.4.19



[2004-07-17 09:58:07] jdittmer at ppp0 dot net

Just wanted to say, that I see the very same error with php 4.3.8 and
postgres. (pconnect  connect) System is Debian/GNU Linux



[2004-07-16 19:51:09] genio at qwest dot net

I've been able to reproduce the error on OpenBSD using php5 and mysql5
alpha. I assumed the error occured due to the fact im using an alpha
release version of mysql, in my case it might not be a php bug because
Im able to reproduce a similar mysql error with a jsp servlet
connection



[2004-07-13 21:25:02] gmartine at adinet dot com dot uy

Hi,

 I have this very same error using php 4.3.7 / mysql 4.0.20a under
windows 2000.

Regards.



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=26490edit=1


#26490 [Com]: Lost connection to MySQL server during query

2004-07-21 Thread florian dot heigl at m4f dot net
 ID:   26490
 Comment by:   florian dot heigl at m4f dot net
 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:

I got the same error w/o using php - connecting via bin/mysql...

It only happens *sometimes* :)
ERROR 2013 at line 78: Lost connection to MySQL server during query


OS is Tru64 5.1B-4, MySQL 4.0.20


Previous Comments:


[2004-07-20 15:00:52] garak at studenti dot it

Same problem.
Connect to mysql server on LAN.
PHP 4.3.7
MySQL 4.0.20
Linux 2.4.19



[2004-07-17 09:58:07] jdittmer at ppp0 dot net

Just wanted to say, that I see the very same error with php 4.3.8 and
postgres. (pconnect  connect) System is Debian/GNU Linux



[2004-07-16 19:51:09] genio at qwest dot net

I've been able to reproduce the error on OpenBSD using php5 and mysql5
alpha. I assumed the error occured due to the fact im using an alpha
release version of mysql, in my case it might not be a php bug because
Im able to reproduce a similar mysql error with a jsp servlet
connection



[2004-07-13 21:25:02] gmartine at adinet dot com dot uy

Hi,

 I have this very same error using php 4.3.7 / mysql 4.0.20a under
windows 2000.

Regards.



[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



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=26490edit=1


#26490 [Com]: Lost connection to MySQL server during query

2004-07-20 Thread garak at studenti dot it
 ID:   26490
 Comment by:   garak at studenti dot it
 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:

Same problem.
Connect to mysql server on LAN.
PHP 4.3.7
MySQL 4.0.20
Linux 2.4.19


Previous Comments:


[2004-07-17 09:58:07] jdittmer at ppp0 dot net

Just wanted to say, that I see the very same error with php 4.3.8 and
postgres. (pconnect  connect) System is Debian/GNU Linux



[2004-07-16 19:51:09] genio at qwest dot net

I've been able to reproduce the error on OpenBSD using php5 and mysql5
alpha. I assumed the error occured due to the fact im using an alpha
release version of mysql, in my case it might not be a php bug because
Im able to reproduce a similar mysql error with a jsp servlet
connection



[2004-07-13 21:25:02] gmartine at adinet dot com dot uy

Hi,

 I have this very same error using php 4.3.7 / mysql 4.0.20a under
windows 2000.

Regards.



[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] [EMAIL PROTECTED]

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.



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=26490edit=1


#26490 [Com]: Lost connection to MySQL server during query

2004-07-17 Thread jdittmer at ppp0 dot net
 ID:   26490
 Comment by:   jdittmer at ppp0 dot net
 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:

Just wanted to say, that I see the very same error with php 4.3.8 and
postgres. (pconnect  connect) System is Debian/GNU Linux


Previous Comments:


[2004-07-16 19:51:09] genio at qwest dot net

I've been able to reproduce the error on OpenBSD using php5 and mysql5
alpha. I assumed the error occured due to the fact im using an alpha
release version of mysql, in my case it might not be a php bug because
Im able to reproduce a similar mysql error with a jsp servlet
connection



[2004-07-13 21:25:02] gmartine at adinet dot com dot uy

Hi,

 I have this very same error using php 4.3.7 / mysql 4.0.20a under
windows 2000.

Regards.



[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] [EMAIL PROTECTED]

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



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=26490edit=1


#26490 [Com]: Lost connection to MySQL server during query

2004-07-16 Thread genio at qwest dot net
 ID:   26490
 Comment by:   genio at qwest dot net
 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:

I've been able to reproduce the error on OpenBSD using php5 and mysql5
alpha. I assumed the error occured due to the fact im using an alpha
release version of mysql, in my case it might not be a php bug because
Im able to reproduce a similar mysql error with a jsp servlet
connection


Previous Comments:


[2004-07-13 21:25:02] gmartine at adinet dot com dot uy

Hi,

 I have this very same error using php 4.3.7 / mysql 4.0.20a under
windows 2000.

Regards.



[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] [EMAIL PROTECTED]

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] [EMAIL PROTECTED]

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)





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=26490edit=1


#26490 [Com]: Lost connection to MySQL server during query

2004-07-13 Thread gmartine at adinet dot com dot uy
 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] [EMAIL PROTECTED]

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] [EMAIL PROTECTED]

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] [EMAIL PROTECTED]

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; $t10; $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; $x10; $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=26490edit=1


#26490 [Com]: Lost connection to MySQL server during query

2004-06-24 Thread phpbug at nathandial dot com
 ID:   26490
 Comment by:   phpbug at nathandial dot com
 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:

I've got the same bug on gentoo. PHP 4.3.6, mysql 4.0.18


Previous Comments:


[2004-06-20 20:22:08] [EMAIL PROTECTED]

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] [EMAIL PROTECTED]

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] [EMAIL PROTECTED]

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; $t10; $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; $x10; $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 ) 




[2003-12-01 13:16:29] chris dot noden at monstermob dot com

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))