#38228 [Fbk->Opn]: Pcntl based parallel threads loose connection to MySQL server
ID: 38228
User updated by: piotr at bulczak dot name
Reported By: piotr at bulczak dot name
-Status: Feedback
+Status: Open
Bug Type: MySQL related
Operating System: Fedora Core 5 Linux
PHP Version: 5.1.4
New Comment:
I compiled php5.2-latest.tar.gz on FC5 with configure options
'--enable-pcntl' '--with-mysql' '--with-mysqli'
'--with-pdo-mysql'.
Undoftunately the bug still exist in this version. My test script
produced again error message "MySQL server has gone away".
Looking for some workaround I noticed that the problem does not occure
if I close all MySQL connections in parrent script before forking
childs. Maybe this info will help to spot problem source.
Previous Comments:
------------------------------------------------------------------------
[2006-07-26 23:23:31] sniper@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.2-win32-latest.zip
------------------------------------------------------------------------
[2006-07-26 20:09:18] piotr at bulczak dot name
Description:
------------
For long time I was using multithreaded scripts (pcntl module). Each
script was using their own connection to MySQL server (mysql module).
They are working properly on FC1 - FC4 linuxes (PHP 4.3.11 - 5.0.4). I
tried for the first time to tun them on FC5 which includes standard rpm
packages - PHP 5.1.4 in this case (iptables and selinux turned off).
I noticed that my threads fail with message "server has gone away" when
using "mysql_select_db. The behaviour is the same regardless if it is
connection via unix socket file, tcp/ip connection to localhost or some
remote IP address. It does not matter what MySQL server version I am
connecting to (tried with 3.23.58 - 5.0.22)
I tried also switch to "mysqli" module on FC5 and the script started
working properly again so I assume only "mysql" module is affected.
I do not have major changes to standard php.ini... just
max_execution_time=300 and memory_limit=32M. Test script is just a
minimal version (without any threads synchronization, etc. stuff).
Please help :-)
Reproduce code:
---------------
http://www.buleksoft.pl/mysql_pcntl_test.html
Expected result:
----------------
[root@host ~]# php -q test.php
Forking thread number 0
Thread 0 doing some mysql tasks
Forking thread number 1
Thread 1 doing some mysql tasks
Forking thread number 2
Thread 2 doing some mysql tasks
Forking thread number 3
Thread 3 doing some mysql tasks
Actual result:
--------------
[root@host ~]# php -q test.php
Forking thread number 0
Thread 0 doing some mysql tasks
Forking thread number 1
Thread 1: Could not select DB because MySQL server has gone away
Forking thread number 2
Thread 2: Could not select DB because MySQL server has gone away
Forking thread number 3
Thread 3: Could not select DB because MySQL server has gone away
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=38228&edit=1
Thread (6 messages)