@@ -929,51 +929,55 @@ get_all_vacuum_rels(int options)
929
929
}
930
930
931
931
/*
932
- * vacuum_set_xid_limits() -- compute oldestXmin and freeze cutoff points
932
+ * vacuum_set_xid_limits() -- compute OldestXmin and freeze cutoff points
933
933
*
934
- * Input parameters are the target relation, applicable freeze age settings .
934
+ * The target relation and VACUUM parameters are our inputs .
935
935
*
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
938
938
* 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
940
940
* 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
944
944
* removed from Xmax during aggressive vacuums.
945
945
*
946
946
* Return value indicates if vacuumlazy.c caller should make its VACUUM
947
947
* 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
949
949
* minimum).
950
950
*
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
952
952
* passed to vac_update_relstats() as frozenxid and minmulti arguments by our
953
953
* vacuumlazy.c caller later on. These values should be passed when it turns
954
954
* out that VACUUM will leave no unfrozen XIDs/MXIDs behind in the table.
955
955
*/
956
956
bool
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 )
966
960
{
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 ;
967
966
TransactionId nextXID ,
968
967
safeOldestXmin ,
969
968
aggressiveXIDCutoff ;
970
969
MultiXactId nextMXID ,
971
970
safeOldestMxact ,
972
971
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 ;
974
978
975
979
/*
976
- * Acquire oldestXmin .
980
+ * Acquire OldestXmin .
977
981
*
978
982
* We can always ignore processes running lazy vacuum. This is because we
979
983
* use these values only for deciding which tuples we must keep in the
@@ -983,14 +987,14 @@ vacuum_set_xid_limits(Relation rel,
983
987
* that only one vacuum process can be working on a particular table at
984
988
* any time, and that each vacuum is always an independent transaction.
985
989
*/
986
- * oldestXmin = GetOldestNonRemovableTransactionId (rel );
990
+ * OldestXmin = GetOldestNonRemovableTransactionId (rel );
987
991
988
992
if (OldSnapshotThresholdActive ())
989
993
{
990
994
TransactionId limit_xmin ;
991
995
TimestampTz limit_ts ;
992
996
993
- if (TransactionIdLimitedForOldSnapshots (* oldestXmin , rel ,
997
+ if (TransactionIdLimitedForOldSnapshots (* OldestXmin , rel ,
994
998
& limit_xmin , & limit_ts ))
995
999
{
996
1000
/*
@@ -1000,15 +1004,15 @@ vacuum_set_xid_limits(Relation rel,
1000
1004
* frequency), but would still be a significant improvement.
1001
1005
*/
1002
1006
SetOldSnapshotThresholdTimestamp (limit_ts , limit_xmin );
1003
- * oldestXmin = limit_xmin ;
1007
+ * OldestXmin = limit_xmin ;
1004
1008
}
1005
1009
}
1006
1010
1007
- Assert (TransactionIdIsNormal (* oldestXmin ));
1011
+ Assert (TransactionIdIsNormal (* OldestXmin ));
1008
1012
1009
- /* Acquire oldestMxact */
1010
- * oldestMxact = GetOldestMultiXactId ();
1011
- Assert (MultiXactIdIsValid (* oldestMxact ));
1013
+ /* Acquire OldestMxact */
1014
+ * OldestMxact = GetOldestMultiXactId ();
1015
+ Assert (MultiXactIdIsValid (* OldestMxact ));
1012
1016
1013
1017
/* Acquire next XID/next MXID values used to apply age-based settings */
1014
1018
nextXID = ReadNextTransactionId ();
@@ -1025,13 +1029,13 @@ vacuum_set_xid_limits(Relation rel,
1025
1029
freeze_min_age = Min (freeze_min_age , autovacuum_freeze_max_age / 2 );
1026
1030
Assert (freeze_min_age >= 0 );
1027
1031
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 ;
1035
1039
1036
1040
/*
1037
1041
* Compute the multixact age for which freezing is urgent. This is
@@ -1052,16 +1056,16 @@ vacuum_set_xid_limits(Relation rel,
1052
1056
effective_multixact_freeze_max_age / 2 );
1053
1057
Assert (multixact_freeze_min_age >= 0 );
1054
1058
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 ;
1062
1066
1063
1067
/*
1064
- * Done setting output parameters; check if oldestXmin or oldestMxact are
1068
+ * Done setting output parameters; check if OldestXmin or OldestMxact are
1065
1069
* held back to an unsafe degree in passing
1066
1070
*/
1067
1071
safeOldestXmin = nextXID - autovacuum_freeze_max_age ;
@@ -1070,12 +1074,12 @@ vacuum_set_xid_limits(Relation rel,
1070
1074
safeOldestMxact = nextMXID - effective_multixact_freeze_max_age ;
1071
1075
if (safeOldestMxact < FirstMultiXactId )
1072
1076
safeOldestMxact = FirstMultiXactId ;
1073
- if (TransactionIdPrecedes (* oldestXmin , safeOldestXmin ))
1077
+ if (TransactionIdPrecedes (* OldestXmin , safeOldestXmin ))
1074
1078
ereport (WARNING ,
1075
1079
(errmsg ("cutoff for removing and freezing tuples is far in the past" ),
1076
1080
errhint ("Close open transactions soon to avoid wraparound problems.\n"
1077
1081
"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 ))
1079
1083
ereport (WARNING ,
1080
1084
(errmsg ("cutoff for freezing multixacts is far in the past" ),
1081
1085
errhint ("Close open transactions soon to avoid wraparound problems.\n"
0 commit comments