Hi, pgstat_read_statsfiles() sets each stat_reset_timestamp to the current timestamp, at the beginning of the function, just in case we fail to load the existing statsfile. This code is originally introduced by commit 4c468b37a2.
But commit ad1b5c842b changed pgstat_read_statsfiles() so that the stats including stat_reset_timestamp are zeroed in that case, so now there seems no need to set each stat_reset_timestamp. Thought? Attached is the patch that removes such unnecessary sets of stat_reset_timestamp from pgstat_read_statsfiles(). Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index 3f8105c6eb..8324a14349 100644 --- a/src/backend/postmaster/pgstat.c +++ b/src/backend/postmaster/pgstat.c @@ -5146,7 +5146,6 @@ pgstat_read_statsfiles(Oid onlydb, bool permanent, bool deep) int32 format_id; bool found; const char *statfile = permanent ? PGSTAT_STAT_PERMANENT_FILENAME : pgstat_stat_filename; - int i; /* * The tables will live in pgStatLocalContext. @@ -5171,19 +5170,6 @@ pgstat_read_statsfiles(Oid onlydb, bool permanent, bool deep) memset(&archiverStats, 0, sizeof(archiverStats)); memset(&slruStats, 0, sizeof(slruStats)); - /* - * Set the current timestamp (will be kept only in case we can't load an - * existing statsfile). - */ - globalStats.stat_reset_timestamp = GetCurrentTimestamp(); - archiverStats.stat_reset_timestamp = globalStats.stat_reset_timestamp; - - /* - * Set the same reset timestamp for all SLRU items too. - */ - for (i = 0; i < SLRU_NUM_ELEMENTS; i++) - slruStats[i].stat_reset_timestamp = globalStats.stat_reset_timestamp; - /* * Try to open the stats file. If it doesn't exist, the backends simply * return zero for anything and the collector simply starts from scratch