Skip to content

Commit 6daeeb1

Browse files
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 <[email protected]> Discussion: https://postgr.es/m/CAH2-WznuNGSzF8v6OsgjaC5aYsb3cZ6HW6MLm30X0d65cmSH6A@mail.gmail.com
1 parent 1fd3dd2 commit 6daeeb1

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/backend/access/heap/vacuumlazy.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -1698,7 +1698,8 @@ lazy_scan_prune(LVRelState *vacrel,
16981698
}
16991699

17001700
/* Track newest xmin on page. */
1701-
if (TransactionIdFollows(xmin, prunestate->visibility_cutoff_xid))
1701+
if (TransactionIdFollows(xmin, prunestate->visibility_cutoff_xid) &&
1702+
TransactionIdIsNormal(xmin))
17021703
prunestate->visibility_cutoff_xid = xmin;
17031704
}
17041705
break;
@@ -1863,7 +1864,7 @@ lazy_scan_prune(LVRelState *vacrel,
18631864
* because visibility_cutoff_xid will be logged by our caller in a
18641865
* moment.
18651866
*/
1866-
Assert(cutoff == FrozenTransactionId ||
1867+
Assert(!TransactionIdIsValid(cutoff) ||
18671868
cutoff == prunestate->visibility_cutoff_xid);
18681869
}
18691870
#endif
@@ -3293,7 +3294,8 @@ heap_page_is_all_visible(LVRelState *vacrel, Buffer buf,
32933294
}
32943295

32953296
/* Track newest xmin on page. */
3296-
if (TransactionIdFollows(xmin, *visibility_cutoff_xid))
3297+
if (TransactionIdFollows(xmin, *visibility_cutoff_xid) &&
3298+
TransactionIdIsNormal(xmin))
32973299
*visibility_cutoff_xid = xmin;
32983300

32993301
/* Check whether this tuple is already frozen or not */

src/backend/storage/ipc/standby.c

+1
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ ResolveRecoveryConflictWithSnapshot(TransactionId snapshotConflictHorizon,
493493
if (!TransactionIdIsValid(snapshotConflictHorizon))
494494
return;
495495

496+
Assert(TransactionIdIsNormal(snapshotConflictHorizon));
496497
backends = GetConflictingVirtualXIDs(snapshotConflictHorizon,
497498
locator.dbOid);
498499
ResolveRecoveryConflictWithVirtualXIDs(backends,

0 commit comments

Comments
 (0)