Skip to content

Commit 2b0a919

Browse files
author
Alexander Korotkov
committed
Remove multixact offset freeze threshold computation.
1 parent 7a1d5a9 commit 2b0a919

File tree

4 files changed

+3
-66
lines changed

4 files changed

+3
-66
lines changed

src/backend/access/transam/multixact.c

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2314,68 +2314,6 @@ ReadMultiXactCounts(uint64 *multixacts, MultiXactOffset *members)
23142314
return true;
23152315
}
23162316

2317-
/*
2318-
* Multixact members can be removed once the multixacts that refer to them
2319-
* are older than every datminxmid. autovacuum_multixact_freeze_max_age and
2320-
* vacuum_multixact_freeze_table_age work together to make sure we never have
2321-
* too many multixacts; we hope that, at least under normal circumstances,
2322-
* this will also be sufficient to keep us from using too many offsets.
2323-
* However, if the average multixact has many members, we might exhaust the
2324-
* members space while still using few enough members that these limits fail
2325-
* to trigger full table scans for relminmxid advancement. At that point,
2326-
* we'd have no choice but to start failing multixact-creating operations
2327-
* with an error.
2328-
*
2329-
* To prevent that, if more than a threshold portion of the members space is
2330-
* used, we effectively reduce autovacuum_multixact_freeze_max_age and
2331-
* to a value just less than the number of multixacts in use. We hope that
2332-
* this will quickly trigger autovacuuming on the table or tables with the
2333-
* oldest relminmxid, thus allowing datminmxid values to advance and removing
2334-
* some members.
2335-
*
2336-
* As the fraction of the member space currently in use grows, we become
2337-
* more aggressive in clamping this value. That not only causes autovacuum
2338-
* to ramp up, but also makes any manual vacuums the user issues more
2339-
* aggressive. This happens because vacuum_set_xid_limits() clamps the
2340-
* freeze table and the minimum freeze age based on the effective
2341-
* autovacuum_multixact_freeze_max_age this function returns. In the worst
2342-
* case, we'll claim the freeze_max_age to zero, and every vacuum of any
2343-
* table will try to freeze every multixact.
2344-
*
2345-
* It's possible that these thresholds should be user-tunable, but for now
2346-
* we keep it simple.
2347-
*/
2348-
int64
2349-
MultiXactMemberFreezeThreshold(void)
2350-
{
2351-
MultiXactOffset members;
2352-
uint64 multixacts;
2353-
uint64 victim_multixacts;
2354-
double fraction;
2355-
2356-
/* If we can't determine member space utilization, assume the worst. */
2357-
if (!ReadMultiXactCounts(&multixacts, &members))
2358-
return 0;
2359-
2360-
/* If member space utilization is low, no special action is required. */
2361-
if (members <= MULTIXACT_MEMBER_SAFE_THRESHOLD)
2362-
return autovacuum_multixact_freeze_max_age;
2363-
2364-
/*
2365-
* Compute a target for relminmxid advancement. The number of multixacts
2366-
* we try to eliminate from the system is based on how far we are past
2367-
* MULTIXACT_MEMBER_SAFE_THRESHOLD.
2368-
*/
2369-
fraction = (double) (members - MULTIXACT_MEMBER_SAFE_THRESHOLD) /
2370-
(MULTIXACT_MEMBER_DANGER_THRESHOLD - MULTIXACT_MEMBER_SAFE_THRESHOLD);
2371-
victim_multixacts = multixacts * fraction;
2372-
2373-
/* fraction could be > 1.0, but lowest possible freeze age is zero */
2374-
if (victim_multixacts > multixacts)
2375-
return 0;
2376-
return multixacts - victim_multixacts;
2377-
}
2378-
23792317
typedef struct mxtruncinfo
23802318
{
23812319
int earliestExistingPage;

src/backend/commands/vacuum.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ vacuum_set_xid_limits(Relation rel,
551551
* normally autovacuum_multixact_freeze_max_age, but may be less if we are
552552
* short of multixact member space.
553553
*/
554-
effective_multixact_freeze_max_age = MultiXactMemberFreezeThreshold();
554+
effective_multixact_freeze_max_age = autovacuum_multixact_freeze_max_age;
555555

556556
/*
557557
* Determine the minimum multixact freeze age to use: as specified by

src/backend/postmaster/autovacuum.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ do_start_worker(void)
11301130

11311131
/* Also determine the oldest datminmxid we will consider. */
11321132
recentMulti = ReadNextMultiXactId();
1133-
multiMembersThreshold = MultiXactMemberFreezeThreshold();
1133+
multiMembersThreshold = autovacuum_multixact_freeze_max_age;
11341134
if (recentMulti > FirstMultiXactId + multiMembersThreshold)
11351135
multiForceLimit = recentMulti - multiMembersThreshold;
11361136
else
@@ -1935,7 +1935,7 @@ do_autovacuum(void)
19351935
* normally autovacuum_multixact_freeze_max_age, but may be less if we are
19361936
* short of multixact member space.
19371937
*/
1938-
effective_multixact_freeze_max_age = MultiXactMemberFreezeThreshold();
1938+
effective_multixact_freeze_max_age = autovacuum_multixact_freeze_max_age;
19391939

19401940
/*
19411941
* Find the pg_database entry and select the default freeze ages. We use

src/include/access/multixact.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ extern void MultiXactSetNextMXact(MultiXactId nextMulti,
138138
extern void MultiXactAdvanceNextMXact(MultiXactId minMulti,
139139
MultiXactOffset minMultiOffset);
140140
extern void MultiXactAdvanceOldest(MultiXactId oldestMulti, Oid oldestMultiDB);
141-
extern int64 MultiXactMemberFreezeThreshold(void);
142141

143142
extern void multixact_twophase_recover(TransactionId xid, uint16 info,
144143
void *recdata, uint32 len);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy