Re: REPACK (CONCURRENTLY) can silently lose updates when the toast table is rewritten

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: Manu <manuelreyesbravo(at)gmail(dot)com>
Cc: shihao zhong <zhong950419(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Thom Brown <thom(at)linux(dot)com>, Antonin Houska <ah(at)cybertec(dot)at>, Robert Treat <rob(at)xzilla(dot)net>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: REPACK (CONCURRENTLY) can silently lose updates when the toast table is rewritten
Date: 2026-09-28 15:35:46
Message-ID: arqEOe67h7Xeu4FB@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2026-Sep-25, Manu wrote:

> Hi,
>
> shihao zhong <zhong950419(at)gmail(dot)com> wrote:
> > Done in v5. 0001 is Álvaro's version as one commit, with that comment
> > added and a shorter commit message. 0002 fixes the decoding_ctx comment
> > in copy_table_data().
>
> I ran v5 through the same checks as v3, on master and on
> REL_19_STABLE, where it applies cleanly.

Thanks! I have pushed this. I apologize for forgetting to list
reviewers in the commit message :-( But I also failed to remember in
time that doing CheckRelationOidLockedByMe() doesn't actually check
anything, and that it needs to be used in conjunction with Assert(). I
have pushed a fix for that and wrote the "Reviewed-by" trailers there.

Anyway, regarding the patch, I changed some comments a little bit more.
The only change of actual significance is that I revisited my earlier
idea of not touching copy_table_data: I did change the lock acquisition
into an assert, when in concurrent mode. This is what Antonin had
suggested back in [1], and I thought would be "not very nice", but I
think I was mistaken.

[1] https://postgr.es/m/4324.1790317455@localhost

Regarding the deadlock when a conflicting lock on the toast table is
acquired during the initial steps, I'm not too worried about it; I think
it's on the spirit of "play stupid games, win you-know-what-kind-of-
prizes", and it hopefully won't be too bad in practice.

--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"No necesitamos banderas
No reconocemos fronteras" (Jorge González)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2026-09-28 15:46:08 Re: Persist slot invalidations before publishing them
Previous Message Andres Freund 2026-09-28 15:24:52 Re: [PATCH] Fix vacuum_delay_point happening inside lock