Hi,
On Mon, Jan 27, 2025 at 03:07:01PM +0000, Bertrand Drouvot wrote:
> On Fri, Jan 24, 2025 at 03:06:17PM -0500, Andres Freund wrote:
> > but in case of an immediate *restart* (via pg_ctl restart -m immediate) we'll
> > not have such hint. postmaster.c doesn't know it's an immediate restart, so
> > that's not surprising, but it still seems a bit weird. One would hope that
> > immediate restarts are more common than crashes...
>
> Yeah, it does not make the distinction between an "immediate restart" and an
> "immediate stop". I agree that such hint "should" be added in case of "immediate
> restart" (and keep "immediate stop" as it is): will give it a look.
I looked at it and learned that an immediate restart is nothing but a stop
followed by a start (do_restart()): "pg_ctl" sends a SIGQUIT to postmaster to
indicate an immediate stop and later asks for a start (do_start()).
So when the postmaster receives the SIGQUIT it has no clue that a start will
follow (as you said up-thread).
I’m not familiar with this area of the code, and just discovered it behaves that
way.
To give quickdie() more context I can see 3 options:
1. Use another signal for an immediate restart (but looking at PostmasterMain()
I don’t see any "good" remaining signal to use)
2. Use a shared memory flag to indicate an immediate restart (but this kind of
"communication" looks to be new between "pg_ctl" and postmaster and might be
over complicating things)
3. Use a new DB_SHUTDOWNING_FOR_RESTART or such in DBState and let pg_ctl modify
the control file? (That way we could give more context to quickdie())
It looks to me that 3. makes the more sense (but as said I'm not familiar with
this code so maybe there is another option one could think of or my proposal
is not appropriate), thoughts?
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com