| From: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
|---|---|
| To: | Antonin Houska <ah(at)cybertec(dot)at> |
| Cc: | Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Mihail Nikalayeu <mihailnikalayeu(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Robert Treat <rob(at)xzilla(dot)net> |
| Subject: | Re: Adding REPACK [concurrently] |
| Date: | 2026-03-20 07:59:23 |
| Message-ID: | 202603200752.zigubezzfcql@alvherre.pgsql |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 2026-Mar-19, Antonin Houska wrote:
> Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
>
> > So here's v43. Here, I've changed the CONCURRENTLY implementation to go
> > through table AM. This necessitated changing it to use tuples in slots
> > instead of HeapTuple. This is good because we can avoid repeated tuple
> > form/deform, which could get pretty expensive. Antonin's 0004 patch
> > here looks suspicious here though, because it deforms the tuple and
> > forms it again, which sounds unnecessary now.
>
> I suppose you mean
> v42-0004-Serialize-decoded-tuples-without-flattening.patch. This deforms the
> tuple to get the external attributes and to write them to file. The tuple the
> logical worker received from reorderbuffer.c cannot be passed to the backend
> executing REPACK because it may contain "external indirect" attributes,
> i.e. pointers to the worker's memory.
No, that patch has been absorbed in what is now v43-0003. I meant
v43-0004 "Use BulkInsertState when copying data to the new heap.",
that's why I said "patch 0004 here". In this patch, we have
reform_tuple which deforms the tuple, sets to NULL any attribute that's
marked dropped, and then forms a new one. This is wasteful and should
probably be done elsewhere, while the tuple is still in slot
representation. In fact, I suspect it may not be necessary at all
anymore.
I haven't verified whether all the code is covered by existing tests;
what I did was just run them. But to ensure that it is all trustworthy,
I'll spend some time with the coverage report to ensure there aren't any
nasty surprises anywhere. The slot/tupdesc interface is notoriously bad
at differentiating 0-based indexes of the attribute array, and 1-based
proper attribute numbers, so it's very easy to do the wrong thing.
(It's worse when you do an even number of wrong things and they cancel
each other out.)
--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"This is what I like so much about PostgreSQL. Most of the surprises
are of the "oh wow! That's cool" Not the "oh shit!" kind. :)"
Scott Marlowe, http://archives.postgresql.org/pgsql-admin/2008-10/msg00152.php
| From | Date | Subject | |
|---|---|---|---|
| Next Message | jian he | 2026-03-20 08:15:12 | Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions |
| Previous Message | 2026-03-20 07:51:50 | RE: synchronized_standby_slots behavior inconsistent with quorum-based synchronous replication |