pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-hackers@lists.postgresql.org
Subject: Re: Subscription tests fail under CLOBBER_CACHE_ALWAYS
Date: Fri, 21 May 2021 19:54:48 -0400
Message-ID: <194914.1621641288@sss.pgh.pa.us> (raw)
In-Reply-To: <165922.1621635259@sss.pgh.pa.us>
References: <3382681.1621381328@sss.pgh.pa.us>
	<165922.1621635259@sss.pgh.pa.us>

I wrote:
> BTW, I wonder whether it wouldn't be a good idea for the
> postmaster to log something along the lines of "stopping
> because restart_after_crash is off".  The present behavior
> can be quite mysterious otherwise (it certainly confused me).

Concretely, I suggest the attached.

While checking the other ExitPostmaster calls to see if any of
them lacked suitable log messages, I noticed that there's one
after a call to AuxiliaryProcessMain, which is marked
pg_attribute_noreturn().  So that's dead code, and if it
weren't dead it'd be wrong, because we shouldn't use
ExitPostmaster to exit a child process.

			regards, tom lane

Attachments:

log-explanation-when-postmaster-shuts-down.patch (text/x-diff, 1.6K) download diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 5327859472..5a050898fe 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -3973,7 +3973,11 @@ PostmasterStateMachine(void) if (ReachedNormalRunning) CancelBackup(); - /* Normal exit from the postmaster is here */ + /* + * Normal exit from the postmaster is here. We don't need to log + * anything here, since the UnlinkLockFiles proc_exit callback + * will do so, and that should be the last user-visible action. + */ ExitPostmaster(0); } } @@ -3985,9 +3989,21 @@ PostmasterStateMachine(void) * startup process fails, because more than likely it will just fail again * and we will keep trying forever. */ - if (pmState == PM_NO_CHILDREN && - (StartupStatus == STARTUP_CRASHED || !restart_after_crash)) - ExitPostmaster(1); + if (pmState == PM_NO_CHILDREN) + { + if (StartupStatus == STARTUP_CRASHED) + { + ereport(LOG, + (errmsg("shutting down due to startup process failure"))); + ExitPostmaster(1); + } + if (!restart_after_crash) + { + ereport(LOG, + (errmsg("shutting down because restart_after_crash is off"))); + ExitPostmaster(1); + } + } /* * If we need to recover from a crash, wait for all non-syslogger children @@ -5439,8 +5455,7 @@ StartChildProcess(AuxProcType type) MemoryContextDelete(PostmasterContext); PostmasterContext = NULL; - AuxiliaryProcessMain(ac, av); - ExitPostmaster(0); + AuxiliaryProcessMain(ac, av); /* does not return */ } #endif /* EXEC_BACKEND */ =

view thread (28+ messages)  latest in thread

Message-ID: <194914.1621641288@sss.pgh.pa.us>
Permalink:  ../194914.1621641288@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/194914.1621641288@sss.pgh.pa.us

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-hackers@lists.postgresql.org
  Subject: Re: Subscription tests fail under CLOBBER_CACHE_ALWAYS
  In-Reply-To: <194914.1621641288@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox