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>, Andres Freund <andres@anarazel.de>
Cc: Justin Pryzby <pryzby@telsasoft.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2022-12-12T23:47:16Z
Lists: pgsql-hackers
On Sat, 2022-12-10 at 18:11 -0800, Peter Geoghegan wrote: > On Tue, Dec 6, 2022 at 1:45 PM Peter Geoghegan <pg@bowt.ie> wrote: > > v9 will also address some of the concerns you raised in your review > > that weren't covered by v8, especially about the VM snapshotting > > infrastructure. But also your concerns about the transition from > > lazy > > strategies to eager strategies. > > Attached is v9. Highlights: Comments: * The documentation shouldn't have a heading like "Managing the 32-bit Transaction ID address space". We already have a concept of "age" documented, and I think that's all that's needed in the relevant section. Freezing is driven by a need to keep the age of the oldest transaction ID in a table to less than ~2B; and also the need to truncate the clog (and reduce lookups of really old xids). It's fine to give a brief explanation about why we can't track very old xids, but it's more of an internal detail and not the main point. * I'm still having a hard time with vacuum_freeze_strategy_threshold. Part of it is the name, which doesn't seem to convey the meaning. But the heuristic also seems off to me. What if you have lots of partitions in an append-only range-partitioned table? That would tend to use the lazy freezing strategy (because each partition is small), but that's not what you want. I understand heuristics aren't perfect, but it feels like we could do something better. Also, another purpose of this seems to be to achieve v15 behavior (if v16 behavior causes a problem for some workload), which seems like a good idea, but perhaps we should have a more direct setting for that? * The comment above lazy_scan_strategy() is phrased in terms of the "traditional approach". It would be more clear if you described the current strategies and how they're chosen. The pre-16 behavior was as lazy as possible, so that's easy enough to describe without referring to history. * "eager skipping behavior" seems like a weird phrasing because it's not immediately clear if that means "skip more pages" (eager to skip pages and lazy to process them) or "skip fewer pages" (lazy to skip the pages and eager to process the pages). * The skipping behavior is for all-visible pages is binary: skip them all, or skip none. That makes sense in the context of relfrozenxid advancement. But how does that avoid IO spikes? It would seem perfectly reasonable to me, if relfrozenxid advancement is not a pressing problem, to process some fraction of the all-visible pages (or perhaps process enough of them to freeze some fraction). That would ensure that each VACUUM makes a payment on the deferred costs of freezing. I think this has already been discussed but it keeps reappearing in my mind, so maybe we can settle this with a comment (and/or docs)? * I'm wondering whether vacuum_freeze_min_age makes sense anymore. It doesn't take effect unless the page is not skipped, which is confusing from a usability standpoint, and we have better heuristics to decide if the whole page should be frozen or not anyway (i.e. if an FPI was already taken then freezing is cheaper). -- Jeff Davis PostgreSQL Contributor Team - AWS
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