[Koha-bugs] [Bug 21872] Elasticsearch indexing faster by making it multi-threaded

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue Apr 30 03:26:55 CEST 2019


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21872

--- Comment #59 from David Cook <dcook at prosentient.com.au> ---
(In reply to Martin Renvoize from comment #57)
> 1) The 'die' on fork failure isn't cleaning up after itself.. imagine a case
> where we want to sporn 5 subprocesses, it we get to process 4 and then run
> out of memory for example. The parent script will die and leave behind
> zombie child processes.

I don't think that this is an actual problem. I think that this happens all the
time. The parent dies, the init process (ie 1) becomes the new parent, and it
reaps the children when they complete. I don't even think they actually do
become zombie child processes in this process. This is also the same process
used to daemonize a process.

Where you run into a problem with zombie child processes is when the parent
lives, the child exits, and the parent doesn't reap the child, which means that
you have zombie child processes filling up your process table. That's a real
problem. 

> 2) It doesn't look like there's any form of signal handling here and as such
> a CTRL+C for example could end up leaving zombie processes too.
> 

You don't need any signal handling. If you do a CTRL+C on the parent process,
it'll cascade down through the child processes, because they'll share the same
process group ID. 

So a CTRL+C won't leave zombie child processes. Even if the CTRL+C just killed
the parent and not the children (e.g. the children had set their own process
group ID after forking), then they'd just be inherited by init and cleaned up
anyway. 

> I'm also wrapping my head around the use of wait vs waitpid here.. I
> remember tripping myself up using them before, but can't remember the
> details well enough right now to be confident I've not missed something.
> 

I think wait() and waitpid(-1) are roughly equivalent? 

They could probably be more rigorous in checking that the PID returned by
wait() actually matches the child PIDs, but not the end of the world. 

Even if the parent forgot to wait and exited early, the child processes would
be cleaned up once they completed.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list