diff options
author | Michael Paquier | 2024-02-01 08:12:50 +0000 |
---|---|---|
committer | Michael Paquier | 2024-02-01 08:12:50 +0000 |
commit | 235c09efbb306d6263e904e484abdf44866beb5e (patch) | |
tree | 01a1599fee9611d210a2b07208edccbc65bfbce3 /src | |
parent | 402388946fb3ac54f0fd5944d7e177ef7737eab2 (diff) |
Fix stats_fetch_consistency with stats for fixed-numbered objects
This impacts the statistics retrieved in transactions for the following
views when updating the value of stats_fetch_consistency, leading to
behaviors contrary to what is documented since 605994651b6a as an update
of this parameter should discard all statistics snapshot data:
- pg_stat_archiver
- pg_stat_bgwriter
- pg_stat_checkpointer
- pg_stat_io
- pg_stat_slru
- pg_stat_wal
For example, updating stats_fetch_consistency from "snapshot" to "cache"
in a transaction did not re-fetch any fresh data, using data cached from
the time when "snapshot" was in use.
Author: Shinya Kato
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 15
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/activity/pgstat.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/backend/utils/activity/pgstat.c b/src/backend/utils/activity/pgstat.c index 125ca97b186..9bfc7a95185 100644 --- a/src/backend/utils/activity/pgstat.c +++ b/src/backend/utils/activity/pgstat.c @@ -943,6 +943,9 @@ pgstat_snapshot_fixed(PgStat_Kind kind) Assert(pgstat_is_kind_valid(kind)); Assert(pgstat_get_kind_info(kind)->fixed_amount); + if (force_stats_snapshot_clear) + pgstat_clear_snapshot(); + if (pgstat_fetch_consistency == PGSTAT_FETCH_CONSISTENCY_SNAPSHOT) pgstat_build_snapshot(); else |