AE Fork Pool reaping problem

Marc Lehmann schmorp at schmorp.de
Tue Mar 21 11:41:34 CET 2017


Hi!

On Wed, Mar 15, 2017 at 11:50:03AM +0000, Michael Wright <mjw at methodanalysis.com> wrote:
> I've been using AnyEvent::Fork::Pool for a while now in a Mojolicious server environment, and it works well, but I recently introduced retirement of worker processes after a certain number of jobs, and discovered this results in zombies.
> 
> Not every retirement does, some are clearly reaped fine, and the ratio of defunct processes to retirements does vary quite a bit (no clue why / according to what), but there are a lot.
> 
> After requesting retirement the child receives and completes remaining jobs, and the worker return value of the last job, is received fine by the parent, a new worker is spawned, it's just that the old process is still there, some of the time.
> 
> Defunct process never result from the worker pool spinning down processes because it is idle, only ever when workers request to be retired.
> 
> Any ideas on what might be the problem?

What is the parent process of the zombie (use ps to find out)? If it's
one of the processes forked by AnyEvent::Fork, then you have to find out
why the kernel doesn't reap them - AnyEvent::Fork sets SIGCHLD to IGNORE,
which means automatic reaping of zombies, but if you take over the process
itself (using ->run), then SIGCHLD is restored to the previous value, and
your code would be responsible for reaping children for example. Likewise
if e.g. SIGCHLD is blocked.

As long as the parent is one of AnyEvent::Fork's template processes or the
template process has exited, there is no way you should get zombies unless
your own code somehow enables it.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\



More information about the anyevent mailing list