Re: New strategies for freezing, advancing relfrozenxid early
Peter Geoghegan <pg@bowt.ie>
From: Peter Geoghegan <pg@bowt.ie>
To: Jeff Davis <pgsql@j-davis.com>
Cc: Matthias van de Meent <boekewurm+postgres@gmail.com>, John Naylor <john.naylor@enterprisedb.com>,
Andres Freund <andres@anarazel.de>, Justin Pryzby <pryzby@telsasoft.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2022-12-26T20:53:52Z
Lists: pgsql-hackers
Attachments
- v12-0002-Add-eager-and-lazy-freezing-strategies-to-VACUUM.patch (application/octet-stream) patch v12-0002
- v12-0004-Finish-removing-aggressive-mode-VACUUM.patch (application/octet-stream) patch v12-0004
- v12-0003-Add-eager-and-lazy-VM-strategies-to-VACUUM.patch (application/octet-stream) patch v12-0003
- v12-0001-Add-page-level-freezing-to-VACUUM.patch (application/octet-stream) patch v12-0001
On Thu, Dec 22, 2022 at 11:39 AM Peter Geoghegan <pg@bowt.ie> wrote: > On Wed, Dec 21, 2022 at 4:53 PM Peter Geoghegan <pg@bowt.ie> wrote: > > Great. I plan on committing 0001 in the next few days. Committing 0002 > > might take a bit longer. > > I pushed the VACUUM cutoffs patch (previously 0001) this morning - > thanks for your help with that one. Attached is v12. I think that the page-level freezing patch is now commitable, and plan on committing it in the next 2-4 days barring any objections. Notable changes in v12: * Simplified some of the logic in FreezeMultiXactId(), which now doesn't have any needless handling of NewRelfrozenXid style cutoffs except in the one case that still needs it (its no-op processing case). We don't need most of the handling on HEAD anymore because every possible approach to processing a Multi other than FRM_NOOP will reliably leave behind a new xmax that is either InvalidTransactionId, or an XID/MXID >= OldestXmin/OldestMxact. Such values cannot possibly need to be tracked by the NewRelfrozenXid trackers, since the trackers are initialized using OldestXmin/OldestMxact to begin with. * v12 merges together the code for the "freeze the page" lazy_scan_prune path with the block that actually calls heap_freeze_execute_prepared(). This should make it clear that pagefrz.freeze_required really does mean that freezing is required. Hopefully that addresses Jeff's recent concern. It's certainly an improvement, in any case. * On a related note, comments around the same point in lazy_scan_prune as well as comments above the HeapPageFreeze struct now explain a concept I decided to call "nominal freezing". This is the case where we "freeze a page" without having any freeze plans to execute. "nominal freezing" is the new name for a concept I invented many months ago, which helps to resolve subtle problems with the way that heap_prepare_freeze_tuple is tasked with doing two different things for its lazy_scan_prune caller: 1. telling lazy_scan_prune how it would freeze each tuple (were it to freeze the page), and 2. helping lazy_scan_prune to determine if the page should become all-frozen in the VM. The latter is always conditioned on page-level freezing actually going ahead, since everything else in heap_prepare_freeze_tuple has to work that way. We always freeze a page with zero freeze plans (or "nominally freeze" the page) in lazy_scan_prune (which is nothing new in itself). We thereby avoid breaking heap_prepare_freeze_tuple's working assumption that all it needs to focus on what the page will look like after freezing executes, while also avoiding senselessly throwing away the ability to set a page all-frozen in the VM in lazy_scan_prune when it'll cost us nothing extra. That is, by always freezing in the event of zero freeze plans, we won't senselessly miss out on setting a page all-frozen in cases where we don't actually have to execute any freeze plans to make that safe, while the "freeze the page path versus don't freeze the page path" dichotomy still works as a high level conceptual abstraction. -- Peter Geoghegan
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