Re: rare avl shutdown slowness (related to signal handling) - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: rare avl shutdown slowness (related to signal handling)
Date
Msg-id 20150407215629.GO4369@alvh.no-ip.org
Whole thread Raw
In response to Re: rare avl shutdown slowness (related to signal handling)  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: rare avl shutdown slowness (related to signal handling)
List pgsql-hackers
Tom Lane wrote:

> That seems like (a) a hack, and (b) not likely to solve the problem
> completely, unless you leave interrupts held throughout proc_exit(),
> which would create all sorts of opportunities for corner case bugs
> during on_proc_exit hooks.
>
> I think changing the outer "for(;;)" to "while (!got_SIGTERM)" would
> be a much safer fix.

Ah, yeah.  I was thinking in changing PG_exception_stack once shutdown
was requested, but this is much simpler.

> It looks like there's a related risk associated with this bit:
>
>     /* in emergency mode, just start a worker and go away */
>     if (!AutoVacuumingActive())
>     {
>         do_start_worker();
>         proc_exit(0);            /* done */
>     }
>
> If we get SIGHUP and see that autovacuum has been turned off,
> we exit the main loop, but we don't set got_SIGTERM.  So if we
> then get a similar error at the shutdown report, we'd not merely
> waste some time, but actually incorrectly launch a child.

Well, what it does is request a new child from postmaster, which
presumably wouldn't be listening; but yeah there's a lot of other work
done here also.

How about the attached?

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

Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: rare avl shutdown slowness (related to signal handling)
Next
From: Tom Lane
Date:
Subject: Re: rare avl shutdown slowness (related to signal handling)