Re: New strategies for freezing, advancing relfrozenxid early
Jeff Davis <pgsql@j-davis.com>
From: Jeff Davis <pgsql@j-davis.com>
To: Peter Geoghegan <pg@bowt.ie>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2022-08-29T18:47:16Z
Lists: pgsql-hackers
On Thu, 2022-08-25 at 14:21 -0700, Peter Geoghegan wrote: > The main high level goal of this work is to avoid painful, disruptive > antiwraparound autovacuums (and other aggressive VACUUMs) that do way > too much "catch up" freezing, all at once, causing significant > disruption to production workloads. Sounds like a good goal, and loosely follows the precedent of checkpoint targets and vacuum cost delays. > A new GUC/reloption called vacuum_freeze_strategy_threshold is added > to control freezing strategy (also influences our choice of skipping > strategy). It defaults to 4GB, so tables smaller than that cutoff > (which are usually the majority of all tables) will continue to > freeze > in much the same way as today by default. Our current lazy approach > to > freezing makes sense there, and should be preserved for its own sake. Why is the threshold per-table? Imagine someone who has a bunch of 4GB partitions that add up to a huge amount of deferred freezing work. The initial problem you described is a system-level problem, so it seems we should track the overall debt in the system in order to keep up. > for this table, at this time: Is it more important to advance > relfrozenxid early (be eager), or to skip all-visible pages instead > (be lazy)? If it's the former, then we must scan every single page > that isn't all-frozen according to the VM snapshot (including every > all-visible page). This feels too absolute, to me. If the goal is to freeze more incrementally, well in advance of wraparound limits, then why can't we just freeze 1000 out of 10000 freezable pages on this run, and then leave the rest for a later run? > Thoughts? What if we thought about this more like a "background freezer". It would keep track of the total number of unfrozen pages in the system, and freeze them at some kind of controlled/adaptive rate. Regular autovacuum's job would be to keep advancing relfrozenxid for all tables and to do other cleanup, and the background freezer's job would be to keep the absolute number of unfrozen pages under some limit. Conceptually those two jobs seem different to me. Also, regarding patch v1-0001-Add-page-level-freezing, do you think that narrows the conceptual gap between an all-visible page and an all- frozen page? Regards, Jeff Davis
Commits
-
Revert "Add eager and lazy freezing strategies to VACUUM."
- 6c6b49726644 16.0 landed
-
Add eager and lazy freezing strategies to VACUUM.
- 4d4179926139 16.0 landed
-
Refine the definition of page-level freezing.
- b37a08323964 16.0 landed
-
Avoid special XID snapshotConflictHorizon values.
- 6daeeb1f9196 16.0 cited
-
Add page-level freezing to VACUUM.
- 1de58df4fec7 16.0 landed
-
Remove overzealous MultiXact freeze assertion.
- 63c844a0a5d7 16.0 landed
-
Refactor how VACUUM passes around its XID cutoffs.
- 4ce3afb82ecf 16.0 landed
-
Deduplicate freeze plans in freeze WAL records.
- 9e5405993c1e 16.0 cited
-
Set relfrozenxid to oldest extant XID seen by VACUUM.
- 0b018fabaaba 15.0 cited
-
Only skip pages marked as clean in the visibility map, if the last 32
- bf136cf6e376 8.4.0 cited
-
Add vacuum_freeze_table_age GUC option, to control when VACUUM should
- 6587818542e7 8.4.0 cited