Skip to content

Commit 6aadd41

Browse files
author
Alexander Korotkov
committed
Fix limits.
1 parent d2554c3 commit 6aadd41

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/backend/commands/vacuum.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,10 @@ vacuum_set_xid_limits(Relation rel,
518518
/*
519519
* Compute the cutoff XID, being careful not to generate a "permanent" XID
520520
*/
521-
limit = *oldestXmin - freezemin;
522-
if (!TransactionIdIsNormal(limit))
521+
limit = *oldestXmin;
522+
if (limit > FirstNormalTransactionId + freezemin)
523+
limit -= freezemin;
524+
else
523525
limit = FirstNormalTransactionId;
524526

525527
/*
@@ -607,8 +609,10 @@ vacuum_set_xid_limits(Relation rel,
607609
* Compute XID limit causing a full-table vacuum, being careful not to
608610
* generate a "permanent" XID.
609611
*/
610-
limit = ReadNewTransactionId() - freezetable;
611-
if (!TransactionIdIsNormal(limit))
612+
limit = ReadNewTransactionId();
613+
if (limit > FirstNormalTransactionId + freezetable)
614+
limit -= freezetable;
615+
else
612616
limit = FirstNormalTransactionId;
613617

614618
*xidFullScanLimit = limit;
@@ -632,8 +636,10 @@ vacuum_set_xid_limits(Relation rel,
632636
* Compute MultiXact limit causing a full-table vacuum, being careful
633637
* to generate a valid MultiXact value.
634638
*/
635-
mxactLimit = ReadNextMultiXactId() - freezetable;
636-
if (mxactLimit < FirstMultiXactId)
639+
mxactLimit = ReadNextMultiXactId();
640+
if (mxactLimit > FirstMultiXactId + freezetable)
641+
mxactLimit -= freezetable;
642+
else
637643
mxactLimit = FirstMultiXactId;
638644

639645
*mxactFullScanLimit = mxactLimit;

0 commit comments

Comments
 (0)