[PATCH] Compressed TOAST data corruption with REPACK CONCURRENTLY
SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>
From: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Álvaro Herrera <alvherre@kurilemu.de>, ah@cybertec.at
Date: 2026-04-16T06:13:42Z
Lists: pgsql-hackers
Attachments
- 0001-Fix-restore_tuple-losing-varlena-compression-flag.patch (application/octet-stream) patch 0001
- 0002-Add-compressed-TOAST-test-to-repack_toast.patch (application/octet-stream) patch 0002
Hi hackers, restore_tuple() in repack.c uses SET_VARSIZE() to reconstruct the varlena header when reading back external attributes from the spill file. In this process, looks like the flag SET_VARSIZE_COMPRESSED is silently lost. Because of this, when REPACK CONCURRENTLY run any concurrently updated column whose value was TOAST-compressed ends up with raw compressed bytes behind an "uncompressed" header returning garbled data on subsequent reads. It appears that existing tests are using random chars which are uncompressable. Please find the attached 0001-Fix-restore_tuple-losing-varlena-compression-flag.patch to fix this. Additionally I updated the existing repack_toast test to include the scenario I was talking about. Thanks, Satya
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
REPACK CONCURRENTLY: fix processing of toasted tuples
- 6ca631b99012 19 (unreleased) landed