Re: oncurrence problem with PEAR:MDB2 + msqli driver in forked CLI environment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 4, 2013 at 6:09 PM, Toni Moreno <toni.moreno@xxxxxxxxx> wrote:

> Hi.
>
> I have a found a very strange and big "concurrence" problem after develop a
> CLI tool which  parallelizes  data processing  by using "pcntrl_fork", ( If
> we run the same executions sequentially the result is correct)
>
> The trouble appears when some of the child processes die while trying to
> access to DB , after child dies, parent process always get status  code of
> 1 or 255..
>
> We can reproduce problem but error messages are not the same always ( I
> attach 3 error log examples)
>
> It seems like a previously stablished connection exists to the bd before
> forking and child processes are working all over it.
>
> Anybody can say me  how can I force child processes to make their own new
> connections  to de BBDD ?
>
>
> Lots of Thanks!!
>
>
First of all, PHP is probably not the right language to do data processing,
but that's up to you.
Second, pcntl_fork is pretty experimental stuff, it's not very stable.

Now to answer your question, it's hard to say without seeing the code, but
I would suspect you only create the database connection once, and use it
from all forks.
The correct way is to create 1 connection per thread, so the threads will
not interfere with each other.

Hope this helps, if not, please show us a small example that demonstrates
the problem.

Regards,

Matijn

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux