Pcntl_fork and PersistenceManager

When i fork via pcntl_fork the whole process will be duplicated including the persistenceManager.

OK. That’s fine.

But when the child has finished the same persitenceManager has been finished and the parent process has no active database connection anylonger. :frowning:

This problem has been solved for Symfony/Doctrine by forcing a new connection to the database :

$conn = $this->getContainer()->get('doctrine')->getConnection();
$conn->close();
$conn->connect();    

Is there a way to handele this problem similar or somehow in FLOW ?

It’s looks like it’s a better approach to let follow the

pcntl_fork() a

pcntl_exec() call

to avoid sharing the same database connection as even a reconnection would force a closing of the old connection, which is still needed by the parent process.

1 Like