diff options
-rw-r--r-- | src/backend/postmaster/pgstat.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index 65b7b328f1f..a0b0eecbd5e 100644 --- a/src/backend/postmaster/pgstat.c +++ b/src/backend/postmaster/pgstat.c @@ -4947,16 +4947,28 @@ pgstat_read_statsfiles(Oid onlydb, bool permanent, bool deep) { ereport(pgStatRunningInCollector ? LOG : WARNING, (errmsg("corrupted statistics file \"%s\"", statfile))); + memset(&globalStats, 0, sizeof(globalStats)); goto done; } /* + * In the collector, disregard the timestamp we read from the permanent + * stats file; we should be willing to write a temp stats file immediately + * upon the first request from any backend. This only matters if the old + * file's timestamp is less than PGSTAT_STAT_INTERVAL ago, but that's not + * an unusual scenario. + */ + if (pgStatRunningInCollector) + globalStats.stats_timestamp = 0; + + /* * Read archiver stats struct */ if (fread(&archiverStats, 1, sizeof(archiverStats), fpin) != sizeof(archiverStats)) { ereport(pgStatRunningInCollector ? LOG : WARNING, (errmsg("corrupted statistics file \"%s\"", statfile))); + memset(&archiverStats, 0, sizeof(archiverStats)); goto done; } @@ -5002,6 +5014,15 @@ pgstat_read_statsfiles(Oid onlydb, bool permanent, bool deep) dbentry->functions = NULL; /* + * In the collector, disregard the timestamp we read from the + * permanent stats file; we should be willing to write a temp + * stats file immediately upon the first request from any + * backend. + */ + if (pgStatRunningInCollector) + dbentry->stats_timestamp = 0; + + /* * Don't create tables/functions hashtables for uninteresting * databases. */ |