php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71125 MongoDB Driver / pcntl_fork() problem
Submitted: 2015-12-15 08:38 UTC Modified: 2015-12-19 19:55 UTC
From: zorg at razza dot org Assigned:
Status: Closed Package: mongo (PECL)
PHP Version: 5.6.16 OS: Ubuntu
Private report: No CVE-ID: None
 [2015-12-15 08:38 UTC] zorg at razza dot org
Description:
------------
When using pcntl_fork() with the new MongoDB\Driver it is impossible to create a new MongoDB manager in the child process if one has been opened in the parent process.

Test script:
---------------
$manager1 = MongoDB\Driver\Manager('mongodb://localhost:27017');

$pid = pcntl_fork();

if ($pid == 0)
{
   // Child process, create a new manager here
   unset($manager1);
   $manager2 = MongoDB\Driver\Manager('mongodb://localhost:27017');

   // Perform queries with $manager2 here
}
else
{
   // Parent process, retain old manager
   // Perform queries with $manager1 here
}

Expected result:
----------------
Expected to have a new MongoDB connection in $manager2 that the child process can use.

Actual result:
--------------
Both managers, even the newly created on in the child process seem to share a socket to MongoDB and throw errors based on receiving each others responses.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-19 19:55 UTC] zorg at razza dot org
Reposted this here:
https://github.com/mongodb/mongo-php-driver/issues/174

As I guess that is where it should be.
 [2015-12-19 19:55 UTC] zorg at razza dot org
-Status: Open +Status: Closed
 [2015-12-19 19:55 UTC] zorg at razza dot org
Closing as moved report to github.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Apr 16 23:01:23 2021 UTC