Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lkEyi-00038K-QA for pgsql-hackers@arkaria.postgresql.org; Fri, 21 May 2021 23:54:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lkEyh-0006fz-IC for pgsql-hackers@arkaria.postgresql.org; Fri, 21 May 2021 23:54:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lkEyh-0006fr-AZ for pgsql-hackers@lists.postgresql.org; Fri, 21 May 2021 23:54:51 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lkEyf-0001qW-6N for pgsql-hackers@lists.postgresql.org; Fri, 21 May 2021 23:54:50 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 14LNsmnL194915 for ; Fri, 21 May 2021 19:54:48 -0400 From: Tom Lane To: pgsql-hackers@lists.postgresql.org Subject: Re: Subscription tests fail under CLOBBER_CACHE_ALWAYS In-reply-to: <165922.1621635259@sss.pgh.pa.us> References: <3382681.1621381328@sss.pgh.pa.us> <165922.1621635259@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Fri, 21 May 2021 18:14:19 -0400" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <194872.1621641244.0@sss.pgh.pa.us> Date: Fri, 21 May 2021 19:54:48 -0400 Message-ID: <194914.1621641288@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <194872.1621641244.1@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 ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="log-explanation-when-postmaster-shuts-down.patch"; charset="us-ascii" Content-ID: <194872.1621641244.2@sss.pgh.pa.us> Content-Description: log-explanation-when-postmaster-shuts-down.patch Content-Transfer-Encoding: quoted-printable 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 aga= in * and we will keep trying forever. */ - if (pmState =3D=3D PM_NO_CHILDREN && - (StartupStatus =3D=3D STARTUP_CRASHED || !restart_after_crash)) - ExitPostmaster(1); + if (pmState =3D=3D PM_NO_CHILDREN) + { + if (StartupStatus =3D=3D 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 childr= en @@ -5439,8 +5455,7 @@ StartChildProcess(AuxProcType type) MemoryContextDelete(PostmasterContext); PostmasterContext =3D NULL; = - AuxiliaryProcessMain(ac, av); - ExitPostmaster(0); + AuxiliaryProcessMain(ac, av); /* does not return */ } #endif /* EXEC_BACKEND */ = ------- =_aaaaaaaaaa0--