php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67061 mysqli don't work with pcntl_fork
Submitted: 2014-04-12 23:16 UTC Modified: 2014-04-12 23:19 UTC
From: aurelien dot lequoy at esysteme dot com Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: 5.5.11 OS: Debian 7.4
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: aurelien dot lequoy at esysteme dot com
New email:
PHP Version: OS:

 

 [2014-04-12 23:16 UTC] aurelien dot lequoy at esysteme dot com
Description:
------------
We have to close connection MySQL before  to use pcntl_wait and repoen it after to make it work.

Or when the son dead and get back with father.

Test script:
---------------
 <?php

 $db = new MySQLi('localhost','root','zeb33tln');

 if (pcntl_fork()) {
     echo "pid du pere ".getmypid().PHP_EOL;
     $status = 0;



    $result = $db->query('select version()');
    if ($db->error) echo "error 1".$db->error.PHP_EOL;

    //pcntl_wait($status);

    $result = $db->query('select version()');
        if ($db->error) echo "error 2".$db->error.PHP_EOL;


 } else {
     echo "pid son ".getmypid().PHP_EOL;


    $result = $db->query('select version()');
 if ($db->error) echo "error 3".$db->error.PHP_EOL;

     exit;
 }


    $result = $db->query('select version()');
 if ($db->error) echo "error 4".$db->error.PHP_EOL;

 echo "END".PHP_EOL;

Expected result:
----------------
pid du pere 26717
pid son 26718
END


Actual result:
--------------
pid du pere 26749
pid son 26750
PHP Warning:  Packets out of order. Expected 1 received 5. Packet size=31 in /home/www/glial/testmysql.php on line 11
PHP Warning:  mysqli::query(): MySQL server has gone away in /home/www/glial/testmysql.php on line 11
PHP Warning:  mysqli::query(): Error reading result set's header in /home/www/glial/testmysql.php on line 11
error 1MySQL server has gone away
error 2MySQL server has gone away
error 4MySQL server has gone away
END
PHP Warning:  Packets out of order. Expected 3 received 0. Packet size=65029 in /home/www/glial/testmysql.php on line 24
PHP Warning:  mysqli::query(): MySQL server has gone away in /home/www/glial/testmysql.php on line 24
error 3MySQL server has gone away

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-04-12 23:19 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2014-04-12 23:19 UTC] requinix@php.net
You cannot use the same connection at once in both processes. Each one needs its own $db.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC