Bug #45797 [Com]: PDO closes connection too early when combined with pcntl_fork()
| From: | xxorax at gmail dot com | Date: | Wed, 18 Jan 2012 17:29:13 +0000 |
| Subject: | Bug #45797 [Com]: PDO closes connection too early when combined with pcntl_fork() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-166589@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=45797&edit=1
ID: 45797
Comment by: xxorax at gmail dot com
Reported by: jketterl at chipxonio dot de
Summary: PDO closes connection too early when combined with
pcntl_fork()
Status: Bogus
Type: Bug
Package: MySQL related
Operating System: linux (debian)
PHP Version: 5.2.6
Block user comment: N
Private report: N
New Comment:
However, I think the problem is not to use differents connections in differents
processes, the problem is to maintain the connection in the parent process,
because there is no solution to keep a mysql connection in a parent after a child
closing.
And I am sorry that php does not seem to become a little bit multi-process, in
default to be multi-threaded...
Previous Comments:
------------------------------------------------------------------------
[2008-08-12 13:30:48] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
That's due to the architecture of PHP, you should use different connections in different
processes else you get all different kinds of random results, and connecting to a MySQL daemon is a
quite cheap operation.
------------------------------------------------------------------------
[2008-08-12 11:46:21] jketterl at chipxonio dot de
Description:
------------
When forking a php skript using pcntl_fork, the PDO connections to a MySQL server are lost as soon
as one of the processes exits (parent or child, which ever exits first) and the remaining process
can't continue to execute queries (or, even worse, is interrupted during an active query).
the code to reproduce is a CLI script as the application i'm working on is one too. you will
need to replace username & password. also, I had to change the file extension in order to make
it downloadable.
Reproduce code:
---------------
http://www.djmacgyver.net/files/test2.php.txt
Expected result:
----------------
before fork
records returned: 1
child
records returned: 1
parent
records returned: 1
after fork
records returned: 1
end
Actual result:
--------------
before fork
records returned: 1
child
records returned: 1
parent
records returned: 1
after fork
SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
#0 /home/jketterl/public_html/me/application/import/test2.php(5): PDO->query('select * from
p...')
#1 /home/jketterl/public_html/me/application/import/test2.php(41): doQuery(Object(PDO))
#2 {main}
end
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=45797&edit=1