From: Andres Freund Date: Fri, 26 Mar 2021 17:52:14 +0000 (-0700) Subject: Schedule ShutdownXLOG() in single user mode using before_shmem_exit(). X-Git-Tag: REL_15_BETA1~1715 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a1bb3d5dbe6a66ae73d7805a63b951793b5d55df;p=thirdparty%2Fpostgresql.git Schedule ShutdownXLOG() in single user mode using before_shmem_exit(). Previously on_shmem_exit() was used. The upcoming shared memory stats patch uses DSM segments to store stats, which can not be used after the dsm_backend_shutdown() call in shmem_exit(). There does not seem to be any reason to do ShutdownXLOG() via on_shmem_exit(), so change it. Author: Andres Freund Discussion: https://postgr.es/m/20210405092914.mmxqe7j56lsjfsej@alap3.anarazel.de Discussion: https://postgr.es/m/20210803023612.iziacxk5syn2r4ut@alap3.anarazel.de --- diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index e37b86494e1..87dc060b201 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -638,7 +638,11 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, /* Reset CurrentResourceOwner to nothing for the moment */ CurrentResourceOwner = NULL; - on_shmem_exit(ShutdownXLOG, 0); + /* + * Use before_shmem_exit() so that ShutdownXLOG() can rely on DSM + * segments etc to work (which in turn is required for pgstats). + */ + before_shmem_exit(ShutdownXLOG, 0); } /*