Re: Support for 8-byte TOAST values (aka the TOAST infinite loop problem)

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Burd, Greg" <greg(at)burd(dot)me>, Nikita Malakhov <hukutoc(at)gmail(dot)com>, Hannu Krosing <hannuk(at)google(dot)com>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Support for 8-byte TOAST values (aka the TOAST infinite loop problem)
Date: 2025-09-30 06:26:14
Message-ID: aNt4Bt619hx00Usp@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
v7-0001-Implement-oid8-data-type.patch text/x-diff 38.7 KB
v7-0002-Refactor-some-TOAST-value-ID-code-to-use-Oid8-ins.patch text/x-diff 15.4 KB
v7-0003-Minimize-footprint-of-TOAST_MAX_CHUNK_SIZE-in-hea.patch text/x-diff 4.6 KB
v7-0004-Renames-around-varatt_external-varatt_external_oi.patch text/x-diff 20.4 KB
v7-0005-Refactor-external-TOAST-pointer-code-for-better-p.patch text/x-diff 46.3 KB
v7-0006-Move-static-inline-routines-of-varatt_external_oi.patch text/x-diff 4.7 KB
v7-0007-Split-VARATT_EXTERNAL_GET_POINTER-for-indirect-an.patch text/x-diff 5.9 KB
v7-0008-Switch-pg_column_toast_chunk_id-return-value-from.patch text/x-diff 3.6 KB
v7-0009-Add-catcache-support-for-OID8OID.patch text/x-diff 1.3 KB
v7-0010-Add-support-for-TOAST-chunk_id-type-in-binary-upg.patch text/x-diff 9.3 KB
v7-0011-Enlarge-OID-generation-to-8-bytes.patch text/x-diff 14.6 KB
v7-0012-Add-relation-option-toast_value_type.patch text/x-diff 6.5 KB
v7-0013-Add-support-for-oid8-TOAST-values.patch text/x-diff 16.9 KB
v7-0014-Add-tests-for-TOAST-relations-with-bigint-as-valu.patch text/x-diff 21.5 KB
v7-0015-Add-new-vartag_external-for-8-byte-TOAST-values.patch text/x-diff 14.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2025-09-30 06:31:24 Re: GB18030-2022 Support in PostgreSQL
Previous Message Yugo Nagata 2025-09-30 06:16:53 Re: Suggestion to add --continue-client-on-abort option to pgbench