Re: BUG #19519: REPACK can fail due to missing chunk for toast value

From: Konstantin Knizhnik <knizhnik(at)garret(dot)ru>
To: Rui Zhao <zhaorui126(at)gmail(dot)com>
Cc: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com>, Imran Zaheer <imran(dot)zhir(at)gmail(dot)com>, Alexander Lakhin <exclusion(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #19519: REPACK can fail due to missing chunk for toast value
Date: 2026-11-12 12:49:12
Message-ID: 4583d289-be87-4f6a-bf7c-71462073fea4@garret.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

Attached is v8 of the fix for the "missing chunk number 0 for toast
value" failures during heap rewrites and non-concurrent index builds.

This is a rebase of Matthias' v7 onto current master, with Rui Zhao's
two follow-up patches folded in, plus a bit of cleanup and one extra
fix for a whole-row expression index.

Compared to v7:

- Rebased onto current master (conflict in tableam.h resolved by
keeping master's slice validation and returning bool with flags).
- Folded in Rui's 0001 (skipped stashed prior versions are counted as
removed, not reported as a rewrite failure) and 0002 (cleanup loop
off-by-ones).
- Replaced the duplicated goto-heavy sort-path and index-build cleanup
with a shared heap_inline_recently_dead_toast() helper.
- Index builds now collect every varlena attribute referenced by the
index definition, expressions (including whole-row Vars) and the
predicate, so a whole-row expression index no longer races the same
way. A new isolation permutation covers that case.
- Dropped the duplicate recovery TAP test in favor of the dblink
isolation spec (as the v7 commit message already planned). Added
sort-path CLUSTER and UPDATE-chain permutations there.
- Comment / include-order / pgindent cleanup; TOAST_MISSING_OK is now
(1 << 0).

Verification on current master:

- make check: all 243 tests passed
- src/test/isolation: all 139 tests passed
- contrib/dblink isolation: rewrite_stale_xmin passed
- The same isolation test on unpatched master fails all 11
permutations with the missing-chunk error (CLUSTER index and sort
paths, VACUUM FULL, REPACK, CREATE INDEX, whole-row expression
index; DELETE and UPDATE chains).

CF entry: https://commitfest.postgresql.org/patch/6824/
I will update it with v8 shortly.

Regards,
Konstantin

On 24/10/2026 18:36, Rui Zhao wrote:
> Thanks for updating the patch. I tested v7 on 4b97fd15fb4 and found the
> UPDATE case from my previous mail still fails, plus two cleanup leaks.
>
> Attached are 0001 and 0002 on top of v7. All tests I ran passed.

Attachment Content-Type Size
v8-0001-Fix-missing-chunk-errors-during-heap-rewrites-and.patch text/x-diff 60.7 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Kacper Kuras 2026-11-12 12:55:06 Re: BUG #18754: Logical replication cannot restart if client sent a copyDone
Previous Message Konstantin Knizhnik 2026-11-12 12:47:34 Re: BUG #19519: REPACK can fail due to missing chunk for toast value