@ -929,51 +929,55 @@ get_all_vacuum_rels(int options)
}
/*
* vacuum_set_xid_limits ( ) - - compute o ldestXmin and freeze cutoff points
* vacuum_set_xid_limits ( ) - - compute O ldestXmin and freeze cutoff points
*
* Input parameters are the target relation , applicable freeze age setting s.
* The target relation and VACUUM parameters are our input s.
*
* The output parameters are :
* - o ldestXmin is the Xid below which tuples deleted by any xact ( that
* Our output parameters are :
* - O ldestXmin is the Xid below which tuples deleted by any xact ( that
* committed ) should be considered DEAD , not just RECENTLY_DEAD .
* - o ldestMxact is the Mxid below which MultiXacts are definitely not
* - O ldestMxact is the Mxid below which MultiXacts are definitely not
* seen as visible by any running transaction .
* - f reezeLimit is the Xid below which all Xids are definitely replaced by
* FrozenTransactionI d during aggressive vacuums .
* - m ultiXactCutoff is the value below which all MultiXactIds are definitely
* - F reezeLimit is the Xid below which all Xids are definitely frozen or
* remove d during aggressive vacuums .
* - M ultiXactCutoff is the value below which all MultiXactIds are definitely
* removed from Xmax during aggressive vacuums .
*
* Return value indicates if vacuumlazy . c caller should make its VACUUM
* operation aggressive . An aggressive VACUUM must advance relfrozenxid up to
* FreezeLimit ( at a minimum ) , and relminmxid up to m ultiXactCutoff ( at a
* FreezeLimit ( at a minimum ) , and relminmxid up to M ultiXactCutoff ( at a
* minimum ) .
*
* oldestXmin and o ldestMxact are the most recent values that can ever be
* OldestXmin and O ldestMxact are the most recent values that can ever be
* passed to vac_update_relstats ( ) as frozenxid and minmulti arguments by our
* vacuumlazy . c caller later on . These values should be passed when it turns
* out that VACUUM will leave no unfrozen XIDs / MXIDs behind in the table .
*/
bool
vacuum_set_xid_limits ( Relation rel ,
int freeze_min_age ,
int multixact_freeze_min_age ,
int freeze_table_age ,
int multixact_freeze_table_age ,
TransactionId * oldestXmin ,
MultiXactId * oldestMxact ,
TransactionId * freezeLimit ,
MultiXactId * multiXactCutoff )
vacuum_set_xid_limits ( Relation rel , const VacuumParams * params ,
TransactionId * OldestXmin , MultiXactId * OldestMxact ,
TransactionId * FreezeLimit , MultiXactId * MultiXactCutoff )
{
int freeze_min_age ,
multixact_freeze_min_age ,
freeze_table_age ,
multixact_freeze_table_age ,
effective_multixact_freeze_max_age ;
TransactionId nextXID ,
safeOldestXmin ,
aggressiveXIDCutoff ;
MultiXactId nextMXID ,
safeOldestMxact ,
aggressiveMXIDCutoff ;
int effective_multixact_freeze_max_age ;
/* Use mutable copies of freeze age parameters */
freeze_min_age = params - > freeze_min_age ;
multixact_freeze_min_age = params - > multixact_freeze_min_age ;
freeze_table_age = params - > freeze_table_age ;
multixact_freeze_table_age = params - > multixact_freeze_table_age ;
/*
* Acquire oldestXmin .
* Acquire O ldestXmin.
*
* We can always ignore processes running lazy vacuum . This is because we
* use these values only for deciding which tuples we must keep in the
@ -983,14 +987,14 @@ vacuum_set_xid_limits(Relation rel,
* that only one vacuum process can be working on a particular table at
* any time , and that each vacuum is always an independent transaction .
*/
* o ldestXmin = GetOldestNonRemovableTransactionId ( rel ) ;
* O ldestXmin = GetOldestNonRemovableTransactionId ( rel ) ;
if ( OldSnapshotThresholdActive ( ) )
{
TransactionId limit_xmin ;
TimestampTz limit_ts ;
if ( TransactionIdLimitedForOldSnapshots ( * o ldestXmin, rel ,
if ( TransactionIdLimitedForOldSnapshots ( * O ldestXmin, rel ,
& limit_xmin , & limit_ts ) )
{
/*
@ -1000,15 +1004,15 @@ vacuum_set_xid_limits(Relation rel,
* frequency ) , but would still be a significant improvement .
*/
SetOldSnapshotThresholdTimestamp ( limit_ts , limit_xmin ) ;
* o ldestXmin = limit_xmin ;
* O ldestXmin = limit_xmin ;
}
}
Assert ( TransactionIdIsNormal ( * o ldestXmin) ) ;
Assert ( TransactionIdIsNormal ( * O ldestXmin) ) ;
/* Acquire o ldestMxact */
* o ldestMxact = GetOldestMultiXactId ( ) ;
Assert ( MultiXactIdIsValid ( * o ldestMxact) ) ;
/* Acquire O ldestMxact */
* O ldestMxact = GetOldestMultiXactId ( ) ;
Assert ( MultiXactIdIsValid ( * O ldestMxact) ) ;
/* Acquire next XID/next MXID values used to apply age-based settings */
nextXID = ReadNextTransactionId ( ) ;
@ -1025,13 +1029,13 @@ vacuum_set_xid_limits(Relation rel,
freeze_min_age = Min ( freeze_min_age , autovacuum_freeze_max_age / 2 ) ;
Assert ( freeze_min_age > = 0 ) ;
/* Compute f reezeLimit, being careful to generate a normal XID */
* f reezeLimit = nextXID - freeze_min_age ;
if ( ! TransactionIdIsNormal ( * f reezeLimit) )
* f reezeLimit = FirstNormalTransactionId ;
/* freezeLimit must always be <= o ldestXmin */
if ( TransactionIdPrecedes ( * oldestXmin , * f reezeLimit) )
* freezeLimit = * o ldestXmin;
/* Compute F reezeLimit, being careful to generate a normal XID */
* F reezeLimit = nextXID - freeze_min_age ;
if ( ! TransactionIdIsNormal ( * F reezeLimit) )
* F reezeLimit = FirstNormalTransactionId ;
/* FreezeLimit must always be <= O ldestXmin */
if ( TransactionIdPrecedes ( * OldestXmin , * F reezeLimit) )
* FreezeLimit = * O ldestXmin;
/*
* Compute the multixact age for which freezing is urgent . This is
@ -1052,16 +1056,16 @@ vacuum_set_xid_limits(Relation rel,
effective_multixact_freeze_max_age / 2 ) ;
Assert ( multixact_freeze_min_age > = 0 ) ;
/* Compute m ultiXactCutoff, being careful to generate a valid value */
* m ultiXactCutoff = nextMXID - multixact_freeze_min_age ;
if ( * m ultiXactCutoff < FirstMultiXactId )
* m ultiXactCutoff = FirstMultiXactId ;
/* multiXactCutoff must always be <= o ldestMxact */
if ( MultiXactIdPrecedes ( * oldestMxact , * m ultiXactCutoff) )
* multiXactCutoff = * o ldestMxact;
/* Compute M ultiXactCutoff, being careful to generate a valid value */
* M ultiXactCutoff = nextMXID - multixact_freeze_min_age ;
if ( * M ultiXactCutoff < FirstMultiXactId )
* M ultiXactCutoff = FirstMultiXactId ;
/* MultiXactCutoff must always be <= O ldestMxact */
if ( MultiXactIdPrecedes ( * OldestMxact , * M ultiXactCutoff) )
* MultiXactCutoff = * O ldestMxact;
/*
* Done setting output parameters ; check if oldestXmin or o ldestMxact are
* Done setting output parameters ; check if OldestXmin or O ldestMxact are
* held back to an unsafe degree in passing
*/
safeOldestXmin = nextXID - autovacuum_freeze_max_age ;
@ -1070,12 +1074,12 @@ vacuum_set_xid_limits(Relation rel,
safeOldestMxact = nextMXID - effective_multixact_freeze_max_age ;
if ( safeOldestMxact < FirstMultiXactId )
safeOldestMxact = FirstMultiXactId ;
if ( TransactionIdPrecedes ( * o ldestXmin, safeOldestXmin ) )
if ( TransactionIdPrecedes ( * O ldestXmin, safeOldestXmin ) )
ereport ( WARNING ,
( errmsg ( " cutoff for removing and freezing tuples is far in the past " ) ,
errhint ( " Close open transactions soon to avoid wraparound problems. \n "
" You might also need to commit or roll back old prepared transactions, or drop stale replication slots. " ) ) ) ;
if ( MultiXactIdPrecedes ( * o ldestMxact, safeOldestMxact ) )
if ( MultiXactIdPrecedes ( * O ldestMxact, safeOldestMxact ) )
ereport ( WARNING ,
( errmsg ( " cutoff for freezing multixacts is far in the past " ) ,
errhint ( " Close open transactions soon to avoid wraparound problems. \n "