diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c index 4bc24d9..14e76fe 100644 --- a/src/backend/access/transam/subtrans.c +++ b/src/backend/access/transam/subtrans.c @@ -340,9 +340,13 @@ TruncateSUBTRANS(TransactionId oldestXact) /* * The cutoff point is the start of the segment containing oldestXact. We - * pass the *page* containing oldestXact to SimpleLruTruncate. + * pass the *page* containing oldestXact to SimpleLruTruncate. We step + * back one transaction to avoid passing a cutoff page that hasn't been + * created yet in the rare case that oldestXact would be the first item on + * a page, and oldestXact == next XID (immediately after vacuum has + * advanced oldestXact to point to an XID that hasn't been created yet). */ - cutoffPage = TransactionIdToPage(oldestXact); + cutoffPage = TransactionIdToPage(oldestXact - 1); SimpleLruTruncate(SubTransCtl, cutoffPage); }