Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.5.0b5

Bug #8926 the connection is destructured when a child fork exits
Submitted: 2006-10-10 10:27 UTC
From: alex at alatest dot com Assigned: lsmith
Status: Wont fix Package: MDB2 (version 2.2.2)
PHP Version: 5.1.2 OS: Linux (maybe all)
Roadmaps: (Not assigned)    
Subscription  


 [2006-10-10 10:27 UTC] alex at alatest dot com (Alexander Kjäll)
Description: ------------ When forking to do some work in the background the database connection gets shut down when the child exits. Test script: --------------- $dsn = array('phptype' => 'mysql', 'username' => 'root', 'password' => '*****', 'hostspec' => '192.168.1.3', 'database' => 'alacalc'); $dbh = MDB2::connect($dsn, $options); $res = $dbh->query("SELECT SourceID,WWW,Name,SourcePic FROM source"); $all = $res->fetchAll(MDB2_FETCHMODE_ASSOC); for($i = 0; $i < count($all); $i++) { if($all[$i]["foo"] == "bar") { $res = $dbh->exec("UPDATE source SET LogoURL='" . $source_newimg . "' WHERE SourceID=" . $row["SourceID"]); $pid = pcntl_fork();//fork the process here if(!$pid) { //child //do something that takes long time exit(0); //child exits here now $dbh is dead } } } Expected result: ---------------- a lot of updates to the database Actual result: -------------- an error the second time the sql in the loop is run

Comments

 [2006-10-11 13:21 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2006-10-11 13:30 UTC] alex at alatest dot com
I haven't tried it with the native code, but it sounds likly that it could be the cause of it. I thought that maybe you did some cleanup when your object got destructed, i was very frustrated when i discovered the reason for my bug after hunting it for an hour. maybe i should push this upstream to the php team.
 [2006-10-12 07:33 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2006-10-25 11:53 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2006-10-29 00:11 UTC] neufeind at php dot net (Stefan Neufeind)
Somehow related: http://bugs.php.net/bug.php?id=31538 They just said that you need a separate connection for each child, no other solution. That was back in 2005 ...
 [2006-10-30 08:14 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!