aboutsummaryrefslogtreecommitdiff
path: root/src/include/utils/guc_hooks.h
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 /src/include/utils/guc_hooks.h
parent4d47eff99cc08255f0ae3cc27dc24cc9b30a32e7 (diff)
downloadpostgresql-605994651b6a4209b418cb09d3c223ca269f7cfc.tar.gz
postgresql-605994651b6a4209b418cb09d3c223ca269f7cfc.zip
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 'src/include/utils/guc_hooks.h')
-rw-r--r--src/include/utils/guc_hooks.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/include/utils/guc_hooks.h b/src/include/utils/guc_hooks.h
index a82a85c9401..2ecb9fc0866 100644
--- a/src/include/utils/guc_hooks.h
+++ b/src/include/utils/guc_hooks.h
@@ -121,6 +121,7 @@ extern void assign_search_path(const char *newval, void *extra);
extern bool check_session_authorization(char **newval, void **extra, GucSource source);
extern void assign_session_authorization(const char *newval, void *extra);
extern void assign_session_replication_role(int newval, void *extra);
+extern void assign_stats_fetch_consistency(int newval, void *extra);
extern bool check_ssl(bool *newval, void **extra, GucSource source);
extern bool check_stage_log_stats(bool *newval, void **extra, GucSource source);
extern bool check_synchronous_standby_names(char **newval, void **extra,