postgresql/src
Michael Paquier 8a7cbfce13 Prevent tuples to be marked as dead in subtransactions on standbys
Dead tuples are ignored and are not marked as dead during recovery, as
it can lead to MVCC issues on a standby because its xmin may not match
with the primary.  This information is tracked by a field called
"xactStartedInRecovery" in the transaction state data, switched on when
starting a transaction in recovery.

Unfortunately, this information was not correctly tracked when starting
a subtransaction, because the transaction state used for the
subtransaction did not update "xactStartedInRecovery" based on the state
of its parent.  This would cause index scans done in subtransactions to
return inconsistent data, depending on how the xmin of the primary
and/or the standby evolved.

This is broken since the introduction of hot standby in efc16ea520, so
backpatch all the way down.

Author: Fei Changhong
Reviewed-by: Kyotaro Horiguchi
Discussion: https://postgr.es/m/tencent_C4D907A5093C071A029712E73B43C6512706@qq.com
Backpatch-through: 12
2023-12-12 17:05:18 +01:00
..
backend Prevent tuples to be marked as dead in subtransactions on standbys 2023-12-12 17:05:18 +01:00
bin Remove some unnecessary includes of "access/xlog_internal.h" 2023-12-10 07:46:06 +01:00
common Provide helper for retrying partial vectored I/O. 2023-12-12 10:57:18 +13:00
fe_utils Remove unneeded assignments in for loop header 2023-11-21 16:10:27 +01:00
include Provide vectored variants of FileRead() and FileWrite(). 2023-12-12 13:12:43 +13:00
interfaces Be more wary about OpenSSL not setting errno on error. 2023-12-11 11:51:56 -05:00
makefiles Remove distprep 2023-11-06 15:18:04 +01:00
pl Don't specify number of dimensions in cases where we don't know it. 2023-11-17 11:29:46 -05:00
port Optimize pg_readv/pg_pwritev single vector case. 2023-11-29 17:19:25 +13:00
template
test Optimize nbtree backward scan boundary cases. 2023-12-08 11:05:17 -08:00
timezone Remove distprep 2023-11-06 15:18:04 +01:00
tools Cache opaque handle for GUC option to avoid repeasted lookups. 2023-12-08 11:16:01 -08:00
tutorial Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
.gitignore
DEVELOPERS
Makefile Remove distprep 2023-11-06 15:18:04 +01:00
Makefile.global.in Don't clean initdb files on template creation failure 2023-12-08 13:42:54 +01:00
Makefile.shlib Stop using "-multiply_defined suppress" on macOS. 2023-09-26 21:06:21 -04:00
meson.build
nls-global.mk Remove distprep 2023-11-06 15:18:04 +01:00