From 8d675c85c58065076b673ea8ee61fa1285748ee3 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 27 May 2007 05:37:50 +0000 Subject: pgstat's on-proc-exit hook has to execute after the last transaction commit or abort within a backend; rearrange InitPostgres processing to make it so. Revealed by just-added Asserts along with ECPG regression tests (hm, I wonder why the core regression tests didn't expose it?). This possibly is another reason for missing stats updates ... --- src/backend/utils/init/postinit.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/backend/utils') diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index daef3199fa6..ff70c8d6a66 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.175 2007/03/13 00:33:42 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.176 2007/05/27 05:37:49 tgl Exp $ * * *------------------------------------------------------------------------- @@ -435,6 +435,10 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, /* Initialize portal manager */ EnablePortalManager(); + /* Initialize stats collection --- must happen before first xact */ + if (!bootstrap) + pgstat_initialize(); + /* * Set up process-exit callback to do pre-shutdown cleanup. This has to * be after we've initialized all the low-level modules like the buffer @@ -587,7 +591,7 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, /* initialize client encoding */ InitializeClientEncoding(); - /* initialize statistics collection for this backend */ + /* report this backend in the PgBackendStatus array */ if (!bootstrap) pgstat_bestart(); -- cgit v1.2.3