Re: Review: Extra Daemons / bgworker

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Markus Wanner <markus(at)bluegap(dot)ch>, kaigai(at)kaigai(dot)gr(dot)jp, PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Review: Extra Daemons / bgworker
Date: 2012-12-06 04:59:31
Message-ID: 20121206045931.GK4673@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andres Freund wrote:
> On 2012-12-05 18:42:42 -0300, Alvaro Herrera wrote:
> > > <para>
> > > <structfield>bgw_sighup</structfield> and <structfield>bgw_sigterm</> are
> > > pointers to functions that will be installed as signal handlers for the new
> > > - process.
> > > + process. XXX: Can they be NULL?
> > > </para>
> >
> > Hm. The code doesn't check, so what happens is probably a bug anyhow.
> > I don't know whether sigaction crashes in this case; its manpage doesn't
> > say. I guess the right thing to do is have RegisterBackgroundWorker
> > check for a NULL sighandler, and set it to something standard if so (say
> > SIG_IGN for SIGHUP and maybe quickdie() or similar for SIGTERM).
>
> Afair a NULL sigaction is used to query the current handler. Which
> indirectly might lead to problems due to the wrong handler being called.
>
> Setting up SIG_IGN and quickdie in that case seems to be sensible.

Here's v9. It adds that change, the tweaked docs, a bug fix (postmaster
would kill itself if there's a process crash and a bgworker is stopped),
and some pgindent and code reordering.
github.com/alvherre/postgres/tree/bgworker contains this submission as
commit fa4731c.

I think we can get this committed as a useful starting point for this
feature.

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachment Content-Type Size
bgworker-9.patch text/x-diff 79.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2012-12-06 05:31:16 Re: why can't plpgsql return a row-expression?
Previous Message Shigeru Hanada 2012-12-06 04:47:22 Re: PATCH: optimized DROP of multiple tables within a transaction