mysqli :: begin_transaction在php fork中失败

I'm wondering if there were any reason why mysqli transactions would not work properly in a php fork (with pcntl_fork()) ?

I have a script which calls another in a php fork, and in this second script I make some database operations in transactional mode. I willingly inserted a bad query insides theses operation, which should stop the script and rollback the db operations. The fact is that the script is stopped as expected but the db changes are present in my database (with no commit called).

I tried to launch my second script manually outside the fork and the behavior is as expected, so the problem must come from the fork.

Any idea?

(I can post my code if needed, but it's a bit bushy and quite difficult to read...)

EDIT: Pseudo code example:

Forking script:

$pid = pcntl_fork();
if ($pid < 0) {
    errorHandling;
} else if ($pid == 0) {// In the son
    sleep(1); // Waiting the father register the son's pid
    $this->pid = getmypid();
    $this->worker = $workerManager->fetchBy(array('pid' => $this->pid)); // Get the worker object from db. It contains info about the fork in order to cleanup when it finished the work.
    $this->launchScript($this->worker->getAction()); // This function just call session_write_close in the son and includes the second script
} else { // In the father
    $worker = new Worker($pid); // Create the db object I talked about in the son
    $workerManager->create($worker); // Put it in db
    Ajax::Response(OK, "Launched", $pid); // Answer the request and exits the process (without waiting the son, this is done by a cron elsewere)
}

Second script pseudo code:

$db = new DB_Cognix(); // Just a mysqli encapsulation
$db->enableTransaction(); // Calls $mysqli->begin_transaction()
try {
/*
** Some DB operations (Inserts, Updates and Selects)
*/
    $db->query("FOOBARBAZ"); // A bad query, the db encapsulation will throw an Exception.
} catch (Throwable $e) {
    $db->rollback(); // calls mysqli::rollback()
    $worker->setErrorMessage($e->getMessage());
    $workerManager->update($worker); // This uses another db object and is not concerned by the transaction
    exit;
}
$db->commit(); // Calls mysqli::commit();
exit("OK");

This second script is stopped at exit; and the worker is updated in DB, but the db operations are done anyway. When calling the second script directly from my browser, it works well, the rollback is done.

EDIT 2: I tried a very simple code to see if fork was the cause, and it works like a charm, so I don't think the problem comes from the fork...

            <?php
        $pid = pcntl_fork();
        if ($pid < 0) {
            exit("ERROR: Fork failed!");
        } else if ($pid == 0) {
            session_write_close();
            fastcgi_finish_request();
            $db = new DB_Cognix("", true);
            $db->enableTransaction();
            for ($i = 0; $i < 10; ++$i) {
                $db->query("INSERT INTO Tests (id1, id2) VALUES ($i, $i)");
            }
            $db->rollback();
            exit();
        } else {
            echo "Child launched";
            session_write_close();
            fastcgi_finish_request();
            $status = 0;
            pcntl_waitpid($pid, $status);
            exit;
        }
        ?>