Re: Support for 8-byte TOAST values (aka the TOAST infinite loop problem)
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: "Burd, Greg" <greg@burd.me>, Nikita Malakhov <hukutoc@gmail.com>, Hannu Krosing <hannuk@google.com>, Postgres hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-09-30T06:26:14Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Add data type oid8, 64-bit unsigned identifier
- b139bd3b6ef0 19 (unreleased) landed
Attachments
- v7-0001-Implement-oid8-data-type.patch (text/x-diff) patch v7-0001
- v7-0002-Refactor-some-TOAST-value-ID-code-to-use-Oid8-ins.patch (text/x-diff) patch v7-0002
- v7-0003-Minimize-footprint-of-TOAST_MAX_CHUNK_SIZE-in-hea.patch (text/x-diff) patch v7-0003
- v7-0004-Renames-around-varatt_external-varatt_external_oi.patch (text/x-diff) patch v7-0004
- v7-0005-Refactor-external-TOAST-pointer-code-for-better-p.patch (text/x-diff) patch v7-0005
- v7-0006-Move-static-inline-routines-of-varatt_external_oi.patch (text/x-diff) patch v7-0006
- v7-0007-Split-VARATT_EXTERNAL_GET_POINTER-for-indirect-an.patch (text/x-diff) patch v7-0007
- v7-0008-Switch-pg_column_toast_chunk_id-return-value-from.patch (text/x-diff) patch v7-0008
- v7-0009-Add-catcache-support-for-OID8OID.patch (text/x-diff) patch v7-0009
- v7-0010-Add-support-for-TOAST-chunk_id-type-in-binary-upg.patch (text/x-diff) patch v7-0010
- v7-0011-Enlarge-OID-generation-to-8-bytes.patch (text/x-diff) patch v7-0011
- v7-0012-Add-relation-option-toast_value_type.patch (text/x-diff) patch v7-0012
- v7-0013-Add-support-for-oid8-TOAST-values.patch (text/x-diff) patch v7-0013
- v7-0014-Add-tests-for-TOAST-relations-with-bigint-as-valu.patch (text/x-diff) patch v7-0014
- v7-0015-Add-new-vartag_external-for-8-byte-TOAST-values.patch (text/x-diff) patch v7-0015
On Tue, Sep 16, 2025 at 02:14:43PM +0900, Michael Paquier wrote: > On Thu, Aug 14, 2025 at 02:49:06PM +0900, Michael Paquier wrote: >> I have dropped the amcheck test patch for now, which was fun but it's >> not really necessary for the "basics". I have done also more tests, >> playing for example with pg_resetwal, installcheck and pg_upgrade >> scenarios. I am wondering if it would be worth doing a pg_resetwal in >> the node doing an installcheck on the instance to be upgraded, bumping >> its next OID to be much larger than 4 billion, actually.. > > Four patches had conflicts with 748caa9dcb68, so rebased as v6. There were a few conflicts, so here is a rebased v7, moving the patch to the next CF. I have been sitting on this patch for six weeks for the moment. Tom, you are registered as a reviewer of the patch. The point of contention of the patch, where I see there is no consensus yet, is if my approach of using a redirection for the external TOAST pointers with a new layer to facilitate the addition of more vartags (aka the 64b value vartag proposed here, concept that could also apply to compression methods later on) is acceptable. Moving to a different approach, like the "brutal" one I am naming upthread where the redirection layer is replaced by changes in all the code paths that need to be touched, would be of course cheaper at runtime as there would be no more redirection, but the maintenance would be a nightmare the more vartags we add, and I have some plans for more of these. Doing the switch would be a few hours work, so that would not be a big deal, I guess. The important part is an agreement about the approach, IMO. Please note that the latest patch set also uses a new reloption to control if 8 byte TOAST values are set (not a GUC), binary upgrades are handled with binary_upgrade.h functions, and the 8-byte OID value uses a dedicated data type, as reviewed upthread. One thing that shows up in the last patch of the set is mentioned in an XXX comment in toast_external_assign_vartag(), if it would be better to use a 4-byte vartag even if we have a 8-byte value in the TOAST table to make the TOAST pointers shorter when a value is less than 4 billions. Not sure how much to do about this one, and there's little point in doing this change without the earlier infrastructure patches if the approach taken is thought as OK, as well. -- Michael