Shift the responsibility for emitting "database system is shut down".

Historically this message has been emitted at the end of ShutdownXLOG().
That's not an insane place for it in a standalone backend, but in the
postmaster environment we've grown a fair amount of stuff that happens
later, including archiver/walsender shutdown, stats collector shutdown,
etc.  Recent buildfarm experimentation showed that on slower machines
there could be many seconds' delay between finishing ShutdownXLOG() and
actual postmaster exit.  That's fairly confusing, both for testing
purposes and for DBAs.  Hence, move the code that prints this message
into UnlinkLockFiles(), so that it comes out just after we remove the
postmaster's pidfile.  That is a more appropriate definition of "is shut
down" from the point of view of "pg_ctl stop", for example.  In general,
removing the pidfile should be the last externally-visible action of
either a postmaster or a standalone backend; compare commit
d73d14c271 for instance.  So this seems
like a reasonably future-proof approach.
This commit is contained in:
Tom Lane 2016-02-11 14:14:07 -05:00
parent c319991bca
commit d18643c4a6
2 changed files with 11 additions and 4 deletions

View File

@ -7948,10 +7948,6 @@ ShutdownXLOG(int code, Datum arg)
ShutdownCommitTs();
ShutdownSUBTRANS();
ShutdownMultiXact();
/* Don't be chatty in standalone mode */
ereport(IsPostmasterEnvironment ? LOG : NOTICE,
(errmsg("database system is shut down")));
}
/*

View File

@ -724,6 +724,17 @@ UnlinkLockFiles(int status, Datum arg)
}
/* Since we're about to exit, no need to reclaim storage */
lock_files = NIL;
/*
* Lock file removal should always be the last externally visible action
* of a postmaster or standalone backend, while we won't come here at all
* when exiting postmaster child processes. Therefore, this is a good
* place to log completion of shutdown. We could alternatively teach
* proc_exit() to do it, but that seems uglier. In a standalone backend,
* use NOTICE elevel to be less chatty.
*/
ereport(IsPostmasterEnvironment ? LOG : NOTICE,
(errmsg("database system is shut down")));
}
/*