From 316b073738e08d26db3da743d6da327b5bd1e390 Mon Sep 17 00:00:00 2001 From: Melanie Plageman Date: Tue, 14 Dec 2021 12:26:56 -0500 Subject: [PATCH v18 2/8] Move backend pgstat initialization earlier Initialize pgstats subsystem earlier during process initialization so that more process types have a backend activity state. Conditionally initializing backend activity state in some types of processes and not in others necessitates surprising special cases later. This particular commit was motivated by single user mode missing a backend activity state. Author: Melanie Plageman Discussion: https://www.postgresql.org/message-id/CAAKRu_aaq33UnG4TXq3S-OSXGWj1QGf0sU%2BECH4tNwGFNERkZA%40mail.gmail.com --- src/backend/utils/init/postinit.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index 7292e51f7d..11f1fec17e 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -623,6 +623,8 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, RegisterTimeout(CLIENT_CONNECTION_CHECK_TIMEOUT, ClientCheckTimeoutHandler); } + pgstat_beinit(); + /* * If this is either a bootstrap process nor a standalone backend, start * up the XLOG machinery, and register to have it closed down at exit. @@ -638,6 +640,7 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, */ CreateAuxProcessResourceOwner(); + pgstat_bestart(); StartupXLOG(); /* Release (and warn about) any buffer pins leaked in StartupXLOG */ ReleaseAuxProcessResources(true); @@ -665,7 +668,6 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, EnablePortalManager(); /* Initialize status reporting */ - pgstat_beinit(); /* * Load relcache entries for the shared system catalogs. This must create @@ -903,10 +905,7 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, * transaction we started before returning. */ if (!bootstrap) - { - pgstat_bestart(); CommitTransactionCommand(); - } return; } -- 2.30.2