postgresql/src/backend
Michael Paquier 605994651b 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
2023-05-10 11:24:30 +09:00
..
access Fix typos in comments 2023-05-02 12:23:08 +09:00
archive Redesign archive modules 2023-02-17 14:26:42 +09:00
backup Fix various typos and incorrect/outdated name references 2023-04-19 13:50:33 +12:00
bootstrap Fix CREATE INDEX progress reporting for multi-level partitioning. 2023-03-25 15:34:03 -04:00
catalog Replace last PushOverrideSearchPath() call with set_config_option(). 2023-05-08 06:14:07 -07:00
commands Replace last PushOverrideSearchPath() call with set_config_option(). 2023-05-08 06:14:07 -07:00
executor Fix ExecCheckPermissions call in RI_Initial_Check 2023-05-04 19:55:56 +02:00
foreign De-Revert "Add support for Kerberos credential delegation" 2023-04-13 08:55:07 -04:00
jit Fix typos in comments 2023-05-02 12:23:08 +09:00
lib Fix ILIST_DEBUG build 2023-01-18 10:26:15 -08:00
libpq NULL is not an ideal way to spell bool "false". 2023-04-14 13:31:51 -04:00
main Remove obsolete defense against strxfrm() bugs. 2023-04-20 13:20:14 +12:00
nodes Fix list_copy_head() with empty Lists 2023-04-20 10:34:46 +12:00
optimizer Handle RLS dependencies in inlined set-returning functions properly. 2023-05-08 10:12:44 -04:00
parser Fix typos in comments 2023-05-02 12:23:08 +09:00
partitioning Revert "Move PartitionPruneInfo out of plan nodes into PlannedStmt" 2023-05-04 12:09:59 +02:00
po meson: add install-{quiet, world} targets 2023-03-23 21:20:18 -07:00
port Update copyright for 2023 2023-01-02 15:00:37 -05:00
postmaster Fix vacuum_cost_delay check for balance calculation. 2023-04-25 13:54:10 +02:00
regex Avoid character classification in regex escape parsing. 2023-04-21 08:19:41 -07:00
replication Fix invalid memory access during the shutdown of the parallel apply worker. 2023-05-09 09:28:06 +05:30
rewrite Fix various typos 2023-04-18 13:23:23 +12:00
snowball Update copyright for 2023 2023-01-02 15:00:37 -05:00
statistics Add SysCacheGetAttrNotNull for guaranteed not-null attrs 2023-03-25 22:49:33 +01:00
storage Fix typo with wait event for SLRU buffer of commit timestamps 2023-05-05 21:25:44 +09:00
tcop Handle logical slot conflicts on standby 2023-04-08 00:05:44 -07:00
tsearch Update tsearch regex memory management. 2023-04-08 22:09:17 +12:00
utils Fix assertion failure when updating stats_fetch_consistency in a transaction 2023-05-10 11:24:30 +09:00
.gitignore
Makefile Redesign archive modules 2023-02-17 14:26:42 +09:00
common.mk Blind attempt to fix LLVM dependency in the backend 2022-09-15 10:53:48 +07:00
meson.build meson: Prevent installation of test files during main install 2023-03-03 07:45:52 +01:00
nls.mk NLS: Put list of available languages into LINGUAS files 2022-07-13 08:19:17 +02:00