aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2024-12-21 23:42:39 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2024-12-21 23:42:52 +0200
commit7cfdb4d1e778349b47e34413a26e931d9b07dda6 (patch)
treeb42b29379439c0832f01cd8f1bfe5bc92f36cfa5
parent0350b876b074dc307b82ba18cd3c7cad46066baf (diff)
downloadpostgresql-7cfdb4d1e778349b47e34413a26e931d9b07dda6.tar.gz
postgresql-7cfdb4d1e778349b47e34413a26e931d9b07dda6.zip
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
-rw-r--r--src/backend/utils/time/snapmgr.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index 7d2b34d4f20..b41c307237f 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -920,7 +920,7 @@ SnapshotResetXmin(void)
if (pairingheap_is_empty(&RegisteredSnapshots))
{
- MyProc->xmin = InvalidTransactionId;
+ MyProc->xmin = TransactionXmin = InvalidTransactionId;
return;
}
@@ -928,7 +928,7 @@ SnapshotResetXmin(void)
pairingheap_first(&RegisteredSnapshots));
if (TransactionIdPrecedes(MyProc->xmin, minSnapshot->xmin))
- MyProc->xmin = minSnapshot->xmin;
+ MyProc->xmin = TransactionXmin = minSnapshot->xmin;
}
/*