postgresql/src/backend
Michael Paquier 59cea09f03 Fix race leading to incorrect conflict cause in InvalidatePossiblyObsoleteSlot()
The invalidation of an active slot is done in two steps:
- Termination of the backend holding it, if any.
- Report that the slot is obsolete, with a conflict cause depending on
the slot's data.

This can be racy because between these two steps the slot mutex would be
released while doing system calls, which means that the effective_xmin
and effective_catalog_xmin could advance during that time, detecting a
conflict cause different than the one originally wanted before the
process owning a slot is terminated.

Holding the mutex longer is not an option, so this commit changes the
code to record the LSNs stored in the slot during the termination of the
process owning the slot.

Bonus thanks to Alexander Lakhin for the various tests and the analysis.

Author: Bertrand Drouvot
Reviewed-by: Michael Paquier, Bharath Rupireddy
Discussion: https://postgr.es/m/ZaTjW2Xh+TQUCOH0@ip-10-97-1-34.eu-west-3.compute.internal
Backpatch-through: 16
2024-02-20 13:43:56 +09:00
..
access Fix locking when fixing an incomplete split of a GIN internal page 2024-01-29 13:46:30 +02:00
archive Redesign archive modules 2023-02-17 14:26:42 +09:00
backup Skip .DS_Store files in server side utils 2024-02-13 13:47:12 +01:00
bootstrap Fix CREATE INDEX progress reporting for multi-level partitioning. 2023-03-25 15:34:03 -04:00
catalog Improve handling of dropped partitioned indexes for REINDEX INDEX 2024-01-18 16:31:38 +09:00
commands Fix assertion if index is dropped during REFRESH CONCURRENTLY 2024-02-05 11:03:03 +02:00
executor Fix indentation in ExecParallelHashIncreaseNumBatches() 2024-01-08 19:57:09 +02:00
foreign Expand some more uses of "deleg" to "delegation" or "delegated". 2023-05-21 10:55:18 -04:00
jit Track LLVM 18 changes. 2024-01-25 13:45:22 +13:00
lib Fix ILIST_DEBUG build 2023-01-18 10:26:15 -08:00
libpq Avoid masking EOF (no-password-supplied) conditions in auth.c. 2024-01-03 17:40:38 -05:00
main Remove obsolete defense against strxfrm() bugs. 2023-04-20 13:20:14 +12:00
nodes Use a safer outfuncs/readfuncs representation for BitStrings. 2024-02-13 12:18:25 -05:00
optimizer Apply band-aid fix for an oversight in reparameterize_path_by_child. 2024-02-01 12:34:21 -05:00
parser Fix propagation of persistence to sequences in ALTER TABLE / ADD COLUMN 2024-02-09 08:09:59 +01:00
partitioning Fix incorrect pruning of NULL partition for boolean IS NOT clauses 2024-02-20 12:50:09 +13:00
po Translation updates 2024-02-05 14:45:29 +01:00
port Close socket in case of errors in setting non-blocking 2024-01-17 11:24:11 +01:00
postmaster Avoid calling proc_exit() in processes forked by system(). 2023-10-17 10:41:58 -05:00
regex Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
replication Fix race leading to incorrect conflict cause in InvalidatePossiblyObsoleteSlot() 2024-02-20 13:43:56 +09:00
rewrite Fix RLS policy usage in MERGE. 2023-08-07 09:27:09 +01:00
snowball Fix the install rule for snowball_create.sql. 2023-05-23 11:15:57 -04:00
statistics Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
storage Fix 'mmap' DSM implementation with allocations larger than 4 GB 2024-02-13 21:24:45 +02:00
tcop Be more rigorous about local variables in PostgresMain(). 2023-07-10 12:14:34 -04:00
tsearch Limit to_tsvector_byid's initial array allocation to something sane. 2023-09-25 11:50:28 -04:00
utils Doc: improve a couple of comments in postgresql.conf.sample. 2024-02-15 16:45:03 -05:00
.gitignore
common.mk Blind attempt to fix LLVM dependency in the backend 2022-09-15 10:53:48 +07:00
Makefile Give postgres.exe the icon of other executables. 2023-06-12 07:40:38 -07:00
meson.build Add win32ver data to meson-built postgres.exe. 2023-06-12 07:40:38 -07:00
nls.mk Add missing gettext triggers 2023-05-10 13:51:51 +02:00