diff options
author | Peter Geoghegan <pg@bowt.ie> | 2023-01-02 10:16:51 -0800 |
---|---|---|
committer | Peter Geoghegan <pg@bowt.ie> | 2023-01-02 10:16:51 -0800 |
commit | 6daeeb1f9196e5d59aa7d5c9ef7ed67b3f3ac4b5 (patch) | |
tree | 43a3c49c362942b80b4e68f664b452514fe87a5f /src | |
parent | 1fd3dd2048991a164c287dc29fdb78b1f7e6e14e (diff) | |
download | postgresql-6daeeb1f9196e5d59aa7d5c9ef7ed67b3f3ac4b5.tar.gz postgresql-6daeeb1f9196e5d59aa7d5c9ef7ed67b3f3ac4b5.zip |
Avoid special XID snapshotConflictHorizon values.
Don't allow VACUUM to WAL-log the value FrozenTransactionId as the
snapshotConflictHorizon of freezing or visibility map related WAL
records.
The only special XID value that's an allowable snapshotConflictHorizon
is InvalidTransactionId, which is interpreted as "record definitely
doesn't require a recovery conflict".
Author: Peter Geoghegan <pg@bowt.ie>
Discussion: https://postgr.es/m/CAH2-WznuNGSzF8v6OsgjaC5aYsb3cZ6HW6MLm30X0d65cmSH6A@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/access/heap/vacuumlazy.c | 8 | ||||
-rw-r--r-- | src/backend/storage/ipc/standby.c | 1 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c index 9923994b50e..5d8fd2fb727 100644 --- a/src/backend/access/heap/vacuumlazy.c +++ b/src/backend/access/heap/vacuumlazy.c @@ -1698,7 +1698,8 @@ retry: } /* Track newest xmin on page. */ - if (TransactionIdFollows(xmin, prunestate->visibility_cutoff_xid)) + if (TransactionIdFollows(xmin, prunestate->visibility_cutoff_xid) && + TransactionIdIsNormal(xmin)) prunestate->visibility_cutoff_xid = xmin; } break; @@ -1863,7 +1864,7 @@ retry: * because visibility_cutoff_xid will be logged by our caller in a * moment. */ - Assert(cutoff == FrozenTransactionId || + Assert(!TransactionIdIsValid(cutoff) || cutoff == prunestate->visibility_cutoff_xid); } #endif @@ -3293,7 +3294,8 @@ heap_page_is_all_visible(LVRelState *vacrel, Buffer buf, } /* Track newest xmin on page. */ - if (TransactionIdFollows(xmin, *visibility_cutoff_xid)) + if (TransactionIdFollows(xmin, *visibility_cutoff_xid) && + TransactionIdIsNormal(xmin)) *visibility_cutoff_xid = xmin; /* Check whether this tuple is already frozen or not */ diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c index f43229dfda6..ede00fee935 100644 --- a/src/backend/storage/ipc/standby.c +++ b/src/backend/storage/ipc/standby.c @@ -493,6 +493,7 @@ ResolveRecoveryConflictWithSnapshot(TransactionId snapshotConflictHorizon, if (!TransactionIdIsValid(snapshotConflictHorizon)) return; + Assert(TransactionIdIsNormal(snapshotConflictHorizon)); backends = GetConflictingVirtualXIDs(snapshotConflictHorizon, locator.dbOid); ResolveRecoveryConflictWithVirtualXIDs(backends, |