Re: Postmaster doesn't send SIGTERM to bgworker during fast shutdownwhen pmState == PM_STARTUP - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Postmaster doesn't send SIGTERM to bgworker during fast shutdownwhen pmState == PM_STARTUP
Date
Msg-id 20180828023136.GE5553@paquier.xyz
Whole thread Raw
In response to Postmaster doesn't send SIGTERM to bgworker during fast shutdown whenpmState == PM_STARTUP  (Alexander Kukushkin <cyberdemn@gmail.com>)
Responses Re: Postmaster doesn't send SIGTERM to bgworker during fast shutdownwhen pmState == PM_STARTUP
List pgsql-hackers
On Sun, Aug 26, 2018 at 06:00:23PM +0200, Alexander Kukushkin wrote:
> it is possible to start bgworker with bgw_start_time =
> BgWorkerStart_PostmasterStart, which will be started immediately after
> postmaster.

Right.

> But if you try to do a fast shutdown while postmaster still in the
> pmState == PM_STARTUP, bgworker will never get SIGTERM and postmaster
> will wait forever.
> At the same time, if you do immediate or smart shutdown, it works fine.
>
> The problem is in the pmdie function. Proposed fix attached.

That seems like a good catch and a correct fix to me.  The handling of
SIGINT is inconsistent with SIGTERM in pmdie().  I would just add a
comment to mention that at this stage only the startup process is
running, and that it has been signaled already.  I'll commit that
tomorrow.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Why hash OIDs?
Next
From: Michael Paquier
Date:
Subject: Re: [HACKERS] Proposal to add work_mem option to postgres_fdw module