Re: Removing more vacuumlazy.c special cases, relfrozenxid optimizations
Robert Haas <robertmhaas@gmail.com>
On Fri, Dec 17, 2021 at 9:30 PM Peter Geoghegan <pg@bowt.ie> wrote: > Can we fully get rid of vacuum_freeze_table_age? Maybe even get rid of > vacuum_freeze_min_age, too? Freezing tuples is a maintenance task for > physical blocks, but we use logical units (XIDs). I don't see how we can get rid of these. We know that catastrophe will ensue if we fail to freeze old XIDs for a sufficiently long time --- where sufficiently long has to do with the number of XIDs that have been subsequently consumed. So it's natural to decide whether or not we're going to wait for cleanup locks on pages on the basis of how old the XIDs they contain actually are. Admittedly, that decision doesn't need to be made at the start of the vacuum, as we do today. We could happily skip waiting for a cleanup lock on pages that contain only newer XIDs, but if there is a page that both contains an old XID and stays pinned for a long time, we eventually have to sit there and wait for that pin to be released. And the best way to decide when to switch to that strategy is really based on the age of that XID, at least as I see it, because it is the age of that XID reaching 2 billion that is going to kill us. I think vacuum_freeze_min_age also serves a useful purpose: it prevents us from freezing data that's going to be modified again or even deleted in the near future. Since we can't know the future, we must base our decision on the assumption that the future will be like the past: if the page hasn't been modified for a while, then we should assume it's not likely to be modified again soon; otherwise not. If we knew the time at which the page had last been modified, it would be very reasonable to use that here - say, freeze the XIDs if the page hasn't been touched in an hour, or whatever. But since we lack such timestamps the XID age is the closest proxy we have. > The > risk mostly comes from how much total work we still need to do to > advance relfrozenxid. If the single old XID is quite old indeed (~1.5 > billion XIDs), but there is only one, then we just have to freeze one > tuple to be able to safely advance relfrozenxid (maybe advance it by a > huge amount!). How long can it take to freeze one tuple, with the > freeze map, etc? I don't really see any reason for optimism here. There could be a lot of unfrozen pages in the relation, and we'd have to troll through all of those in order to find that single old XID. Moreover, there is nothing whatsoever to focus autovacuum's attention on that single old XID rather than anything else. Nothing in the autovacuum algorithm will cause it to focus its efforts on that single old XID at a time when there's no pin on the page, or at a time when that XID becomes the thing that's holding back vacuuming throughout the cluster. A lot of vacuum problems that users experience today would be avoided if autovacuum had perfect knowledge of what it ought to be prioritizing at any given time, or even some knowledge. But it doesn't, and is often busy fiddling while Rome burns. IOW, the time that it takes to freeze that one tuple *in theory* might be small. But in practice it may be very large, because we won't necessarily get around to it on any meaningful time frame. -- Robert Haas EDB: http://www.enterprisedb.com
Commits
-
Have VACUUM warn on relfrozenxid "in the future".
- e83ebfe6d767 15.0 landed
-
vacuumlazy.c: Further consolidate resource allocation.
- c42a6fc41dc2 15.0 landed
-
Generalize how VACUUM skips all-frozen pages.
- f3c15cbe5065 15.0 landed
-
Set relfrozenxid to oldest extant XID seen by VACUUM.
- 0b018fabaaba 15.0 landed
-
Doc: Add relfrozenxid Tip to XID wraparound section.
- 05023a237c05 15.0 landed
-
vacuumlazy.c: document vistest and OldestXmin.
- 73f6ec3d3c8d 15.0 cited
-
Increase hash_mem_multiplier default to 2.0.
- 8f388f6f554b 15.0 cited
-
Consolidate VACUUM xid cutoff logic.
- efa4a9462a07 15.0 landed
-
Add VACUUM instrumentation for scanned pages, relfrozenxid.
- 872770fd6ccf 15.0 landed
-
Simplify lazy_scan_heap's handling of scanned pages.
- 44fa84881fff 15.0 landed
-
Try to stabilize reloptions test, again.
- b700f96cffd9 15.0 cited
-
Unify VACUUM VERBOSE and autovacuum logging.
- 49c9d9fcfa9a 15.0 cited
-
Fix possible HOT corruption when RECENTLY_DEAD changes to DEAD while pruning.
- 18b87b201f73 15.0 cited
-
pg_resetxlog: add option to set oldest xid & use by pg_upgrade
- 74cf7d46a91d 15.0 cited
-
Teach VACUUM to bypass unnecessary index vacuuming.
- 5100010ee4d5 14.0 cited
-
Centralize horizon determination for temp tables, fixing bug due to skew.
- 94bc27b57680 14.0 cited
-
pg_surgery: Try to stabilize regression tests.
- 0811f766fd74 14.0 cited
-
Add "split after new tuple" nbtree optimization.
- f21668f328c8 12.0 cited
-
Fix bugs in vacuum of shared rels, by keeping their relcache entries current.
- a54e1f158779 11.0 cited
-
Avoid useless truncation attempts during VACUUM.
- e842908233bb 9.6.0 cited
-
Only skip pages marked as clean in the visibility map, if the last 32
- bf136cf6e376 8.4.0 cited
-
Fix recently-understood problems with handling of XID freezing, particularly
- 48188e1621bb 8.2.0 cited