On Wed, Sep 6, 2017 at 11:50 AM, Alvaro Herrera <alvhe...@alvh.no-ip.org>
wrote:

> Magnus Hagander wrote:
> > On Mon, Sep 4, 2017 at 3:21 PM, Jeff Janes <jeff.ja...@gmail.com> wrote:
>
> > > Should the parent process of pg_basebackup be made to respond to
> SIGCHLD?
> > > Or call waitpid(bgchild, &status, WNOHANG) in some strategic loop?
> >
> > I think it's ok to just call waitpid() -- we don't need to react super
> > quickly, but we should react.
>
> Hmm, not sure about that ... in the normal case (slotname is correct)
> you'd be doing thousands of useless waitpid() system calls during the
> whole operation, no?  I think it'd be better to have a SIGCHLD handler
> that sets a flag (just once), which can be quickly checked without
> accessing kernel space.
>

Good point.

So the question is what to do for Windows. I'd rather not have to bring in
the whole extra thread and socket emulation stuff into pg_basebackup if it
can be avoided. But I guess we could code up something Windows-specific in
just that one (since it's threaded and not processed on Windows, it's
easier than the backend). I think that means we'd have to rewrite it to use
the async libpq apis, don't you?

The other option would be to just kill the process from the child thread.
Since the're threads we can do that. However, that will leave us in a
position where we can't clean up from the error (as in remove files/dirs),
not sure that's good?


-- 
 Magnus Hagander
 Me: https://www.hagander.net/ <http://www.hagander.net/>
 Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/>

Reply via email to