From f1e237b6b2e1199cdda995dd655c68b0174c8fdb Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Mon, 25 Aug 2008 18:55:43 +0000 Subject: [PATCH] Unconditionally write the statsfile when SIGHUP is received, to minimize the window during which backends have no statistics file to read. --- doc/src/sgml/config.sgml | 6 +++--- src/backend/postmaster/pgstat.c | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 3eca0bab84..757ee2a3db 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -1,4 +1,4 @@ - + Server Configuration @@ -3419,8 +3419,8 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv; pg_stat_tmp. Pointing this at a RAM based filesystem will decrease physical I/O requirements and can lead to increased performance. If this parameter is changed when the system is running, - the statistics functions might return no information until a new - file has been written, which typically happens twice per second. + there is a small window of time until the new file has been written + during which the statistics functions might return no information. diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index c822b35d00..990b10e8ff 100644 --- a/src/backend/postmaster/pgstat.c +++ b/src/backend/postmaster/pgstat.c @@ -13,7 +13,7 @@ * * Copyright (c) 2001-2008, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.180 2008/08/25 15:11:00 mha Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.181 2008/08/25 18:55:43 mha Exp $ * ---------- */ #include "postgres.h" @@ -2638,11 +2638,14 @@ PgstatCollectorMain(int argc, char *argv[]) /* * Reload configuration if we got SIGHUP from the postmaster. + * Also, signal a new write of the file, so we drop a new file as + * soon as possible of the directory for it changes. */ if (got_SIGHUP) { ProcessConfigFile(PGC_SIGHUP); got_SIGHUP = false; + need_statwrite = true; } /* -- 2.40.0