Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb607484

Browse files
Simplify vacuum_set_xid_limits() signature.
Pass VACUUM parameters (VacuumParams state) to vacuum_set_xid_limits()directly, rather than passing most individual VacuumParams fields asseparate arguments.Also make vacuum_set_xid_limits() output parameter symbol names matchthose used by its vacuumlazy.c caller.Author: Peter Geoghegan <pg@bowt.ie>Discussion:https://postgr.es/m/CAH2-Wz=TE7gW5DgSahDkf0UEZigFGAoHNNN6EvSrdzC=Kn+hrA@mail.gmail.com
1 parent02d647b commitb607484

File tree

4 files changed

+58
-61
lines changed

4 files changed

+58
-61
lines changed

‎src/backend/access/heap/vacuumlazy.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,7 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
360360
* an aggressive VACUUM then lazy_scan_heap cannot leave behind unfrozen
361361
* XIDs < FreezeLimit (all MXIDs < MultiXactCutoff also need to go away).
362362
*/
363-
aggressive=vacuum_set_xid_limits(rel,
364-
params->freeze_min_age,
365-
params->multixact_freeze_min_age,
366-
params->freeze_table_age,
367-
params->multixact_freeze_table_age,
368-
&OldestXmin,&OldestMxact,
363+
aggressive=vacuum_set_xid_limits(rel,params,&OldestXmin,&OldestMxact,
369364
&FreezeLimit,&MultiXactCutoff);
370365

371366
skipwithvm= true;

‎src/backend/commands/cluster.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@ copy_table_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, bool verbose,
823823
Form_pg_classrelform;
824824
TupleDescoldTupDescPG_USED_FOR_ASSERTS_ONLY;
825825
TupleDescnewTupDescPG_USED_FOR_ASSERTS_ONLY;
826+
VacuumParamsparams;
826827
TransactionIdOldestXmin,
827828
FreezeXid;
828829
MultiXactIdOldestMxact,
@@ -914,7 +915,8 @@ copy_table_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, bool verbose,
914915
* Since we're going to rewrite the whole table anyway, there's no reason
915916
* not to be aggressive about this.
916917
*/
917-
vacuum_set_xid_limits(OldHeap,0,0,0,0,&OldestXmin,&OldestMxact,
918+
memset(&params,0,sizeof(VacuumParams));
919+
vacuum_set_xid_limits(OldHeap,&params,&OldestXmin,&OldestMxact,
918920
&FreezeXid,&MultiXactCutoff);
919921

920922
/*

‎src/backend/commands/vacuum.c

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -929,51 +929,55 @@ get_all_vacuum_rels(int options)
929929
}
930930

931931
/*
932-
* vacuum_set_xid_limits() -- computeoldestXmin and freeze cutoff points
932+
* vacuum_set_xid_limits() -- computeOldestXmin and freeze cutoff points
933933
*
934-
*Input parameters are thetarget relation, applicable freeze age settings.
934+
*Thetarget 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 definitelyreplaced 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 definitelyfrozen 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 tomultiXactCutoff (at a
948+
* FreezeLimit (at a minimum), and relminmxid up toMultiXactCutoff (at a
949949
* minimum).
950950
*
951-
*oldestXmin andoldestMxact are the most recent values that can ever be
951+
*OldestXmin andOldestMxact 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
*/
956956
bool
957-
vacuum_set_xid_limits(Relationrel,
958-
intfreeze_min_age,
959-
intmultixact_freeze_min_age,
960-
intfreeze_table_age,
961-
intmultixact_freeze_table_age,
962-
TransactionId*oldestXmin,
963-
MultiXactId*oldestMxact,
964-
TransactionId*freezeLimit,
965-
MultiXactId*multiXactCutoff)
957+
vacuum_set_xid_limits(Relationrel,constVacuumParams*params,
958+
TransactionId*OldestXmin,MultiXactId*OldestMxact,
959+
TransactionId*FreezeLimit,MultiXactId*MultiXactCutoff)
966960
{
961+
intfreeze_min_age,
962+
multixact_freeze_min_age,
963+
freeze_table_age,
964+
multixact_freeze_table_age,
965+
effective_multixact_freeze_max_age;
967966
TransactionIdnextXID,
968967
safeOldestXmin,
969968
aggressiveXIDCutoff;
970969
MultiXactIdnextMXID,
971970
safeOldestMxact,
972971
aggressiveMXIDCutoff;
973-
inteffective_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-
* AcquireoldestXmin.
980+
* AcquireOldestXmin.
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
TransactionIdlimit_xmin;
991995
TimestampTzlimit_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-
/* AcquireoldestMxact */
1010-
*oldestMxact=GetOldestMultiXactId();
1011-
Assert(MultiXactIdIsValid(*oldestMxact));
1013+
/* AcquireOldestMxact */
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-
/* ComputefreezeLimit, 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+
/* ComputeFreezeLimit, 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-
/* ComputemultiXactCutoff, 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+
/* ComputeMultiXactCutoff, 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 ifoldestXmin oroldestMxact are
1068+
* Done setting output parameters; check ifOldestXmin orOldestMxact 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"

‎src/include/commands/vacuum.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -286,15 +286,11 @@ extern void vac_update_relstats(Relation relation,
286286
bool*frozenxid_updated,
287287
bool*minmulti_updated,
288288
boolin_outer_xact);
289-
externboolvacuum_set_xid_limits(Relationrel,
290-
intfreeze_min_age,
291-
intmultixact_freeze_min_age,
292-
intfreeze_table_age,
293-
intmultixact_freeze_table_age,
294-
TransactionId*oldestXmin,
295-
MultiXactId*oldestMxact,
296-
TransactionId*freezeLimit,
297-
MultiXactId*multiXactCutoff);
289+
externboolvacuum_set_xid_limits(Relationrel,constVacuumParams*params,
290+
TransactionId*OldestXmin,
291+
MultiXactId*OldestMxact,
292+
TransactionId*FreezeLimit,
293+
MultiXactId*MultiXactCutoff);
298294
externboolvacuum_xid_failsafe_check(TransactionIdrelfrozenxid,
299295
MultiXactIdrelminmxid);
300296
externvoidvac_update_datfrozenxid(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp