Re: Postmaster doesn't send SIGTERM to bgworker during fast shutdown when pmState == PM_STARTUP

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Alexander Kukushkin <cyberdemn(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Postmaster doesn't send SIGTERM to bgworker during fast shutdown when pmState == PM_STARTUP
Date: 2018-08-28 02:34:55
Message-ID: 20180828023136.GE5553@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2018-08-28 02:38:19 Re: [HACKERS] Proposal to add work_mem option to postgres_fdw module
Previous Message Tom Lane 2018-08-28 02:26:44 Re: Why hash OIDs?