Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d18643c

Browse filesBrowse files
committed
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 d73d14c for instance. So this seems like a reasonably future-proof approach.
1 parent c319991 commit d18643c
Copy full SHA for d18643c

File tree

Expand file treeCollapse file tree

2 files changed

+11
-4
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-4
lines changed

‎src/backend/access/transam/xlog.c

Copy file name to clipboardExpand all lines: src/backend/access/transam/xlog.c
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7948,10 +7948,6 @@ ShutdownXLOG(int code, Datum arg)
79487948
ShutdownCommitTs();
79497949
ShutdownSUBTRANS();
79507950
ShutdownMultiXact();
7951-
7952-
/* Don't be chatty in standalone mode */
7953-
ereport(IsPostmasterEnvironment ? LOG : NOTICE,
7954-
(errmsg("database system is shut down")));
79557951
}
79567952

79577953
/*

‎src/backend/utils/init/miscinit.c

Copy file name to clipboardExpand all lines: src/backend/utils/init/miscinit.c
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,17 @@ UnlinkLockFiles(int status, Datum arg)
724724
}
725725
/* Since we're about to exit, no need to reclaim storage */
726726
lock_files = NIL;
727+
728+
/*
729+
* Lock file removal should always be the last externally visible action
730+
* of a postmaster or standalone backend, while we won't come here at all
731+
* when exiting postmaster child processes. Therefore, this is a good
732+
* place to log completion of shutdown. We could alternatively teach
733+
* proc_exit() to do it, but that seems uglier. In a standalone backend,
734+
* use NOTICE elevel to be less chatty.
735+
*/
736+
ereport(IsPostmasterEnvironment ? LOG : NOTICE,
737+
(errmsg("database system is shut down")));
727738
}
728739

729740
/*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.