I am working on a job scheduling module that forks a php process in order to run jobs in parallel on Drupal and ran into "MySQL server gone away" problems ( see http://us.php.net/manual/en/function.pcntl-fork.php#70721 ).
The only work around to this problem involves unsetting the MySQL connection, however this is impossible in Drupal because it is saved in the static variable cache in db_set_active. The attached patch changes this static variable to a global so you have the ability to unset the variable outside of the function.
I understand this isn't a clean solution for core, and that such a solution will probably never get into 6, but I wanted to post this issue to save other people some time.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 423126-2.patch | 689 bytes | DeFr |
| db_allow_fork.patch | 495 bytes | andrewlevine |
Comments
Comment #1
dave reidWhat might be better is adding a $reset parameter to the function. Marking as won't fix per instructions.
Comment #2
DeFr commentedComment #3
DeFr commentedHuum, let's try again, the comment attached to the previous patch seems to have been lost somehow.
The patch in comment 2 shows what an approach based on a $reset flag for the function would look like. Note that we can't just unset $db_conns[$name] as it would destroy the object and thus close the connection for the child.
Comment #4
driki_ commentedsubscribe
Comment #5
driki_ commentedoups sorry for messing up status
Comment #6
dave reidAnd again... :)
Comment #7
andrewlevine commentedYou might still get the "Server gone away" problems if you use the patch in #2 because the reference to the sql link will still get copied to the child.
Comment #8
mikeytown2 commentedIf your looking to do something similar check out http://drupal.org/project/httprl