Hi, Firstly, i'm using PHP 4.3.8 and MySQL 4.0.20, on Linux. PHP is connecting to MySQL over a local socket connection.
I have a PHP script that runs constantly on one of my servers. It basically does some processing work with data in a MySQL database, pnctl_fork()s a child process to do some slow-ish task afterwards (posting some data to a less-than-reliable webserver, and then modifying an SQL table with the results), and sleeps for 10 seconds. It wasn't too often that the child process in question was still running during the next iteration of the loop in the parent, but i assume that if it was the situation i describe below would also have cropped up then. So, okay, the above was working fine. Then i added some code /after/ the fork, but before sleeping and the next iteration of the loop, which executes in the parent. So now the likelihood of both parent and children attempting to run SQL queries at the same time increases quite a bit. Since adding the above mentioned code, i now get "Lost connection to MySQL server during query". Not often, though - at most it seems to occur once a day, often only every couple of days, with this script running 24/7. I've searched mailing lists, and Google. This is the most promising thing google turned up: http://bugs.php.net/bug.php?id=26490 However, i'd anticipated that multiple processes using one resource would cause problems, and inside the child i create a new MySQL resource and use that. I'm using the exact same parameters to MySQL connect in the child as the parent, except i am supplying new_link, and setting it to true. I've checked and double checked all my MySQL functions in the child are using this new SQL resource, and they are. I am calling mysql_close($theresource) before the child process exits. In the parent, i am not specifying a resource - however, PHP should use the last resource link opened AFAIK, and as far as the parent process is concerned no other link has ever been opened. I mean, the most likely candidate for the cause of this problem is the whole processes trying to write to one connection symultaneously thing - especially as the problem didn't manifest itself until i added SQL queries immediately after on both sides of the fork... but unless new_link isn't working, i don't see how it can be the cause of this issue. To investigate my suspicion that it's not opening a new link, i've set tcpdump going on the server and will analyse the dumpfile once the error crops up again - however i'm posting here asking for advice as i really need to get it fixed /soon/. I thought someone might have other ideas. Has anyone else had similar problems? Any ideas? I've checked the MySQL server error logs. There doesn't seem to be anything related to this problem in there at all. Thanks a lot for any assistance, i'm tearing my hair out over this one :( - Daniel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php