summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2023-05-10 11:24:30 +0900
committerMichael Paquier <michael@paquier.xyz>2023-05-10 11:24:30 +0900
commit605994651b6a4209b418cb09d3c223ca269f7cfc (patch)
treeb65232b6ef02413cf2bbe5a0f9c910bd7f164fa7 /doc
parent4d47eff99cc08255f0ae3cc27dc24cc9b30a32e7 (diff)
downloadpostgresql-605994651b6a4209b418cb09d3c223ca269f7cfc.tar.gz
Fix assertion failure when updating stats_fetch_consistency in a transaction
An update of the GUC stats_fetch_consistency in a transaction would be able to trigger an assertion when doing cache->snapshot. In this case, when retrieving a pgstat entry after the switch, a new snapshot would be rebuilt, confusing pgstat_build_snapshot() because a snapshot is already cached with an unexpected mode ("cache"). In order to fix this problem, this commit adds a flag to force a snapshot clear each time this GUC is changed. Some tests are added to check, while on it. Some optimizations in avoiding the snapshot clear should be possible depending on what is cached and the current GUC value, I guess, but this solution is simple, and ensures that the state of the cache is updated each time a new pgstat entry is fetched, hence being consistent with the level wanted by the client that has set the GUC. Note that cache->none and snapshot->none would not cause issues, as fetching a pgstat entry would be retrieved from shared memory on the second attempt, however a snapshot would still be cached. Similarly, none->snapshot and none->cache would build a new snapshot on the second fetch attempt. Finally, snapshot->cache would cache a new snapshot on the second attempt. Reported-by: Alexander Lakhin Author: Kyotaro Horiguchi Discussion: https://postgr.es/m/17804-2a118cd046f2d0e5@postgresql.org backpatch-through: 15
Diffstat (limited to 'doc')
-rw-r--r--doc/src/sgml/config.sgml5
1 files changed, 3 insertions, 2 deletions
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index b56f073a91..909a3f28c7 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -8219,8 +8219,9 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
called. When set to <literal>snapshot</literal>, the first statistics
access caches all statistics accessible in the current database, until
the end of the transaction unless
- <function>pg_stat_clear_snapshot()</function> is called. The default
- is <literal>cache</literal>.
+ <function>pg_stat_clear_snapshot()</function> is called. Changing this
+ parameter in a transaction discards the statistics snapshot.
+ The default is <literal>cache</literal>.
</para>
<note>
<para>