Skip to content

Commit 9c1afd3

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 2280912 commit 9c1afd3

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
@@ -1045,15 +1045,15 @@ SnapshotResetXmin(void)
10451045

10461046
if (pairingheap_is_empty(&RegisteredSnapshots))
10471047
{
1048-
MyPgXact->xmin = InvalidTransactionId;
1048+
MyPgXact->xmin = TransactionXmin = InvalidTransactionId;
10491049
return;
10501050
}
10511051

10521052
minSnapshot = pairingheap_container(SnapshotData, ph_node,
10531053
pairingheap_first(&RegisteredSnapshots));
10541054

10551055
if (TransactionIdPrecedes(MyPgXact->xmin, minSnapshot->xmin))
1056-
MyPgXact->xmin = minSnapshot->xmin;
1056+
MyPgXact->xmin = TransactionXmin = minSnapshot->xmin;
10571057
}
10581058

10591059
/*

0 commit comments

Comments
 (0)