ID: 23649 Updated by: [EMAIL PROTECTED] Reported By: sthomas at townnews dot com -Status: Open +Status: Bogus Bug Type: MySQL related Operating System: Redhat Linux 9.0 PHP Version: 4.3.2RC2 New Comment:
You can't use same connection. You have to establish a new connection inside the forked process. Previous Comments: ------------------------------------------------------------------------ [2003-05-16 08:40:59] sthomas at townnews dot com Actually yes, it does. The fork itself seems to be causing this. All I have to do to see that is comment out the fork/exit and it works just fine. Unfortunately one of our crazy developers wrote a daemon that maintains a connection to our database and distributes it to child forks to avoid innundating our DB with connections, so this is really screwing us. It still does this at least all the way back to PHP 4.3.0 - as that's what we're running in production and where we first noticed this. And I'm not sure it's related, but the PHP 4.3.0 version would print the "This is before the fork!" twice, as if the child was running the whole script. It doesn't do this in PHP 4.3.2RC2, but after doing a diff to the pcntl code between those versions, there are no differences. I can't personally see how internals would affect the forking model, so I don't know what's going on. I can provide you with a strace if you need it - since I can't get a backtrace. ------------------------------------------------------------------------ [2003-05-15 18:51:41] [EMAIL PROTECTED] Does this work if you don't have pcntl_fork() there? ------------------------------------------------------------------------ [2003-05-15 17:41:58] sthomas at townnews dot com To reproduce, simply run this script from the PHP CLI: <?PHP print "This is before the fork!\n"; mysql_connect('remote.host', 'user', 'pass'); mysql_select_db('database'); print "Query 1:"; mysql_query('select 1'); print mysql_error(); print "\n"; if (pcntl_fork()) exit(); print "Query 2:"; mysql_query('select 1'); print mysql_error(); print "\n"; mysql_close(); ?> This will almost always produce a "Lost connection to MySQL server during query" error for the second query. Though I did notice that it seems to happen only if the host is a remote host. We are using PHP 4.0.12 as the server, and this bug seems to occour whether we use the included mysql client libraries or compile against the 4.0.12 libraries. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=23649&edit=1