Skip to content

Commit 78853f7

Browse files
michaelpqpull[bot]
authored andcommitted
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 efc16ea, 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
1 parent bf8afa0 commit 78853f7

File tree

1 file changed

+1
-0
lines changed
  • src/backend/access/transam

1 file changed

+1
-0
lines changed

src/backend/access/transam/xact.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5299,6 +5299,7 @@ PushTransaction(void)
52995299
s->blockState = TBLOCK_SUBBEGIN;
53005300
GetUserIdAndSecContext(&s->prevUser, &s->prevSecContext);
53015301
s->prevXactReadOnly = XactReadOnly;
5302+
s->startedInRecovery = p->startedInRecovery;
53025303
s->parallelModeLevel = 0;
53035304
s->topXidLogged = false;
53045305

0 commit comments

Comments
 (0)