@@ -929,51 +929,55 @@ get_all_vacuum_rels(int options)
929929}
930930
931931/*
932- * vacuum_set_xid_limits() -- compute oldestXmin and freeze cutoff points
932+ * vacuum_set_xid_limits() -- compute OldestXmin and freeze cutoff points
933933 *
934- * Input parameters are the target relation, applicable freeze age settings .
934+ * The target relation and VACUUM parameters are our inputs .
935935 *
936- * The output parameters are:
937- * - oldestXmin is the Xid below which tuples deleted by any xact (that
936+ * Our output parameters are:
937+ * - OldestXmin is the Xid below which tuples deleted by any xact (that
938938 * committed) should be considered DEAD, not just RECENTLY_DEAD.
939- * - oldestMxact is the Mxid below which MultiXacts are definitely not
939+ * - OldestMxact is the Mxid below which MultiXacts are definitely not
940940 * seen as visible by any running transaction.
941- * - freezeLimit is the Xid below which all Xids are definitely replaced by
942- * FrozenTransactionId during aggressive vacuums.
943- * - multiXactCutoff is the value below which all MultiXactIds are definitely
941+ * - FreezeLimit is the Xid below which all Xids are definitely frozen or
942+ * removed during aggressive vacuums.
943+ * - MultiXactCutoff is the value below which all MultiXactIds are definitely
944944 * removed from Xmax during aggressive vacuums.
945945 *
946946 * Return value indicates if vacuumlazy.c caller should make its VACUUM
947947 * operation aggressive. An aggressive VACUUM must advance relfrozenxid up to
948- * FreezeLimit (at a minimum), and relminmxid up to multiXactCutoff (at a
948+ * FreezeLimit (at a minimum), and relminmxid up to MultiXactCutoff (at a
949949 * minimum).
950950 *
951- * oldestXmin and oldestMxact are the most recent values that can ever be
951+ * OldestXmin and OldestMxact are the most recent values that can ever be
952952 * passed to vac_update_relstats() as frozenxid and minmulti arguments by our
953953 * vacuumlazy.c caller later on. These values should be passed when it turns
954954 * out that VACUUM will leave no unfrozen XIDs/MXIDs behind in the table.
955955 */
956956bool
957- vacuum_set_xid_limits (Relation rel ,
958- int freeze_min_age ,
959- int multixact_freeze_min_age ,
960- int freeze_table_age ,
961- int multixact_freeze_table_age ,
962- TransactionId * oldestXmin ,
963- MultiXactId * oldestMxact ,
964- TransactionId * freezeLimit ,
965- MultiXactId * multiXactCutoff )
957+ vacuum_set_xid_limits (Relation rel , const VacuumParams * params ,
958+ TransactionId * OldestXmin , MultiXactId * OldestMxact ,
959+ TransactionId * FreezeLimit , MultiXactId * MultiXactCutoff )
966960{
961+ int freeze_min_age ,
962+ multixact_freeze_min_age ,
963+ freeze_table_age ,
964+ multixact_freeze_table_age ,
965+ effective_multixact_freeze_max_age ;
967966 TransactionId nextXID ,
968967 safeOldestXmin ,
969968 aggressiveXIDCutoff ;
970969 MultiXactId nextMXID ,
971970 safeOldestMxact ,
972971 aggressiveMXIDCutoff ;
973- int effective_multixact_freeze_max_age ;
972+
973+ /* Use mutable copies of freeze age parameters */
974+ freeze_min_age = params -> freeze_min_age ;
975+ multixact_freeze_min_age = params -> multixact_freeze_min_age ;
976+ freeze_table_age = params -> freeze_table_age ;
977+ multixact_freeze_table_age = params -> multixact_freeze_table_age ;
974978
975979 /*
976- * Acquire oldestXmin .
980+ * Acquire OldestXmin .
977981 *
978982 * We can always ignore processes running lazy vacuum. This is because we
979983 * use these values only for deciding which tuples we must keep in the
@@ -983,14 +987,14 @@ vacuum_set_xid_limits(Relation rel,
983987 * that only one vacuum process can be working on a particular table at
984988 * any time, and that each vacuum is always an independent transaction.
985989 */
986- * oldestXmin = GetOldestNonRemovableTransactionId (rel );
990+ * OldestXmin = GetOldestNonRemovableTransactionId (rel );
987991
988992 if (OldSnapshotThresholdActive ())
989993 {
990994 TransactionId limit_xmin ;
991995 TimestampTz limit_ts ;
992996
993- if (TransactionIdLimitedForOldSnapshots (* oldestXmin , rel ,
997+ if (TransactionIdLimitedForOldSnapshots (* OldestXmin , rel ,
994998 & limit_xmin , & limit_ts ))
995999 {
9961000 /*
@@ -1000,15 +1004,15 @@ vacuum_set_xid_limits(Relation rel,
10001004 * frequency), but would still be a significant improvement.
10011005 */
10021006 SetOldSnapshotThresholdTimestamp (limit_ts , limit_xmin );
1003- * oldestXmin = limit_xmin ;
1007+ * OldestXmin = limit_xmin ;
10041008 }
10051009 }
10061010
1007- Assert (TransactionIdIsNormal (* oldestXmin ));
1011+ Assert (TransactionIdIsNormal (* OldestXmin ));
10081012
1009- /* Acquire oldestMxact */
1010- * oldestMxact = GetOldestMultiXactId ();
1011- Assert (MultiXactIdIsValid (* oldestMxact ));
1013+ /* Acquire OldestMxact */
1014+ * OldestMxact = GetOldestMultiXactId ();
1015+ Assert (MultiXactIdIsValid (* OldestMxact ));
10121016
10131017 /* Acquire next XID/next MXID values used to apply age-based settings */
10141018 nextXID = ReadNextTransactionId ();
@@ -1025,13 +1029,13 @@ vacuum_set_xid_limits(Relation rel,
10251029 freeze_min_age = Min (freeze_min_age , autovacuum_freeze_max_age / 2 );
10261030 Assert (freeze_min_age >= 0 );
10271031
1028- /* Compute freezeLimit , being careful to generate a normal XID */
1029- * freezeLimit = nextXID - freeze_min_age ;
1030- if (!TransactionIdIsNormal (* freezeLimit ))
1031- * freezeLimit = FirstNormalTransactionId ;
1032- /* freezeLimit must always be <= oldestXmin */
1033- if (TransactionIdPrecedes (* oldestXmin , * freezeLimit ))
1034- * freezeLimit = * oldestXmin ;
1032+ /* Compute FreezeLimit , being careful to generate a normal XID */
1033+ * FreezeLimit = nextXID - freeze_min_age ;
1034+ if (!TransactionIdIsNormal (* FreezeLimit ))
1035+ * FreezeLimit = FirstNormalTransactionId ;
1036+ /* FreezeLimit must always be <= OldestXmin */
1037+ if (TransactionIdPrecedes (* OldestXmin , * FreezeLimit ))
1038+ * FreezeLimit = * OldestXmin ;
10351039
10361040 /*
10371041 * Compute the multixact age for which freezing is urgent. This is
@@ -1052,16 +1056,16 @@ vacuum_set_xid_limits(Relation rel,
10521056 effective_multixact_freeze_max_age / 2 );
10531057 Assert (multixact_freeze_min_age >= 0 );
10541058
1055- /* Compute multiXactCutoff , being careful to generate a valid value */
1056- * multiXactCutoff = nextMXID - multixact_freeze_min_age ;
1057- if (* multiXactCutoff < FirstMultiXactId )
1058- * multiXactCutoff = FirstMultiXactId ;
1059- /* multiXactCutoff must always be <= oldestMxact */
1060- if (MultiXactIdPrecedes (* oldestMxact , * multiXactCutoff ))
1061- * multiXactCutoff = * oldestMxact ;
1059+ /* Compute MultiXactCutoff , being careful to generate a valid value */
1060+ * MultiXactCutoff = nextMXID - multixact_freeze_min_age ;
1061+ if (* MultiXactCutoff < FirstMultiXactId )
1062+ * MultiXactCutoff = FirstMultiXactId ;
1063+ /* MultiXactCutoff must always be <= OldestMxact */
1064+ if (MultiXactIdPrecedes (* OldestMxact , * MultiXactCutoff ))
1065+ * MultiXactCutoff = * OldestMxact ;
10621066
10631067 /*
1064- * Done setting output parameters; check if oldestXmin or oldestMxact are
1068+ * Done setting output parameters; check if OldestXmin or OldestMxact are
10651069 * held back to an unsafe degree in passing
10661070 */
10671071 safeOldestXmin = nextXID - autovacuum_freeze_max_age ;
@@ -1070,12 +1074,12 @@ vacuum_set_xid_limits(Relation rel,
10701074 safeOldestMxact = nextMXID - effective_multixact_freeze_max_age ;
10711075 if (safeOldestMxact < FirstMultiXactId )
10721076 safeOldestMxact = FirstMultiXactId ;
1073- if (TransactionIdPrecedes (* oldestXmin , safeOldestXmin ))
1077+ if (TransactionIdPrecedes (* OldestXmin , safeOldestXmin ))
10741078 ereport (WARNING ,
10751079 (errmsg ("cutoff for removing and freezing tuples is far in the past" ),
10761080 errhint ("Close open transactions soon to avoid wraparound problems.\n"
10771081 "You might also need to commit or roll back old prepared transactions, or drop stale replication slots." )));
1078- if (MultiXactIdPrecedes (* oldestMxact , safeOldestMxact ))
1082+ if (MultiXactIdPrecedes (* OldestMxact , safeOldestMxact ))
10791083 ereport (WARNING ,
10801084 (errmsg ("cutoff for freezing multixacts is far in the past" ),
10811085 errhint ("Close open transactions soon to avoid wraparound problems.\n"
0 commit comments