Skip to content

Commit 41eafbb

Browse files
committed
Update TransactionXmin when MyProc->xmin is updated
GetSnapshotData() set TransactionXmin = MyProc->xmin, but when SnapshotResetXmin() advanced MyProc->xmin, it did not advance TransactionXmin correspondingly. That meant that TransactionXmin could be older than MyProc->xmin, and XIDs between than TransactionXmin and the real MyProc->xmin could be vacuumed away. One known consequence is in pg_subtrans lookups: we might try to look up the status of an XID that was already truncated away. Back-patch to all supported versions. Reviewed-by: Andres Freund Discussion: https://www.postgresql.org/message-id/d27a046d-a1e4-47d1-a95c-fbabe41debb4@iki.fi
1 parent 23c743b commit 41eafbb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/backend/utils/time/snapmgr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,15 +948,15 @@ SnapshotResetXmin(void)
948948

949949
if (pairingheap_is_empty(&RegisteredSnapshots))
950950
{
951-
MyProc->xmin = InvalidTransactionId;
951+
MyProc->xmin = TransactionXmin = InvalidTransactionId;
952952
return;
953953
}
954954

955955
minSnapshot = pairingheap_container(SnapshotData, ph_node,
956956
pairingheap_first(&RegisteredSnapshots));
957957

958958
if (TransactionIdPrecedes(MyProc->xmin, minSnapshot->xmin))
959-
MyProc->xmin = minSnapshot->xmin;
959+
MyProc->xmin = TransactionXmin = minSnapshot->xmin;
960960
}
961961

962962
/*

0 commit comments

Comments
 (0)