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

From: Manu <manuelreyesbravo(at)gmail(dot)com>
To: shihao zhong <zhong950419(at)gmail(dot)com>
Cc: Antonin Houska <ah(at)cybertec(dot)at>, Robert Treat <rob(at)xzilla(dot)net>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Thom Brown <thom(at)linux(dot)com>, 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-25 06:13:40
Message-ID: 179031682043.622163.16451343164955142463@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Shihao,

shihao zhong <zhong950419(at)gmail(dot)com> wrote:
> The rewrite gets the error if those finish within deadlock_timeout,
> otherwise REPACK does.

That matches what I see with v3 on master (e27f3b2cad7), using the
same checks as for v2. With Thom's sequence (a transaction open for
3 s, VACUUM FULL of the TOAST relation meanwhile) and the default
deadlock_timeout of 1 s, REPACK got "deadlock detected" in all 6 runs.
With deadlock_timeout = 5s, REPACK finished and the VACUUM FULL got
the error in all 3. No update was lost in any run; master loses it
every time.

One case differs from v2: a transaction that already has an XID runs
REINDEX on the TOAST relation, with no rewrite, during the startup.
On master and with v2, REPACK completes; with v3 it gets "deadlock
detected", at both timeouts. ALTER TABLE on the table itself
deadlocks the same way on master, as you said.

repack_toast fails without 0001 and passed 20 of 20 runs with it;
check and the isolation suite pass. The script and output are
attached.

Regards,
Manu

Attachment Content-Type Size
nocfbot-repack-toast-v3-check.txt text/plain 16.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2026-09-25 06:15:20 Re: Up to 50x degradation in dblink performance when receiving notice traffic 19 vs 18
Previous Message Bertrand Drouvot 2026-09-25 05:54:41 Re: Persist slot invalidations before publishing them