diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index e37b86494e..87dc060b20 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); } /*