agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
pgsql: Fix heap_update() ignoring TABLE_UPDATE_NO_LOGICAL for TOAST tup
2+ messages / 1 participants
[nested] [flat]

* pgsql: Fix heap_update() ignoring TABLE_UPDATE_NO_LOGICAL for TOAST tup
@ 2026-09-11 17:21 Masahiko Sawada <msawada@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Masahiko Sawada @ 2026-09-11 17:21 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix heap_update() ignoring TABLE_UPDATE_NO_LOGICAL for TOAST tuples.

Previously, heap_update() honored TABLE_UPDATE_NO_LOGICAL for the main
tuple but passed a hardcoded 0 to the tuple toaster, so the tuples it
wrote to the TOAST relation were logged for decoding anyway. That was
harmless until commit 28d534e2ae0a gave updates the flag; the insert
path has propagated its own ever since suppression was introduced for
heap rewrites.

REPACK (CONCURRENTLY), the only user of the flag, relies on it to keep
the changes it applies to the transient heap out of the logical
stream. Logical decoding therefore reassembled the TOAST value and
then dereferenced a new tuple that the suppressed record doesn't
carry, crashing the backend. This is reachable only if an output
plugin asks for the changes made by heap rewrites. In core that is
just test_decoding with include-rewrites.

Fix this by passing HEAP_INSERT_NO_LOGICAL down to the tuple toaster
when TABLE_UPDATE_NO_LOGICAL is set.

Backpatch to v19, where REPACK (CONCURRENTLY) was introduced.

Reported-by: Thom Brown <thom@linux.com>
Author: Antonin Houska <ah@cybertec.at>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Zhijie Hou (Fujitsu) <houzj.fnst@fujitsu.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/CAA-aLv7L_-dOuHXjLh0Di66dExdOb=uTOzR=jtrqCmV0Wxyd2Q@mail.gmail.com
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7164dcb6653242f757b5bdc4a26714a24207b1db

Modified Files
--------------
src/backend/access/heap/heapam.c                   |  8 ++-
src/test/modules/injection_points/Makefile         |  3 ++
.../injection_points/expected/repack_decode.out    | 36 +++++++++++++
src/test/modules/injection_points/meson.build      |  1 +
.../injection_points/specs/repack_decode.spec      | 60 ++++++++++++++++++++++
5 files changed, 106 insertions(+), 2 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Fix heap_update() ignoring TABLE_UPDATE_NO_LOGICAL for TOAST tup
@ 2026-09-11 17:22 Masahiko Sawada <msawada@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Masahiko Sawada @ 2026-09-11 17:22 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix heap_update() ignoring TABLE_UPDATE_NO_LOGICAL for TOAST tuples.

Previously, heap_update() honored TABLE_UPDATE_NO_LOGICAL for the main
tuple but passed a hardcoded 0 to the tuple toaster, so the tuples it
wrote to the TOAST relation were logged for decoding anyway. That was
harmless until commit 28d534e2ae0a gave updates the flag; the insert
path has propagated its own ever since suppression was introduced for
heap rewrites.

REPACK (CONCURRENTLY), the only user of the flag, relies on it to keep
the changes it applies to the transient heap out of the logical
stream. Logical decoding therefore reassembled the TOAST value and
then dereferenced a new tuple that the suppressed record doesn't
carry, crashing the backend. This is reachable only if an output
plugin asks for the changes made by heap rewrites. In core that is
just test_decoding with include-rewrites.

Fix this by passing HEAP_INSERT_NO_LOGICAL down to the tuple toaster
when TABLE_UPDATE_NO_LOGICAL is set.

Backpatch to v19, where REPACK (CONCURRENTLY) was introduced.

Reported-by: Thom Brown <thom@linux.com>
Author: Antonin Houska <ah@cybertec.at>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Zhijie Hou (Fujitsu) <houzj.fnst@fujitsu.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/CAA-aLv7L_-dOuHXjLh0Di66dExdOb=uTOzR=jtrqCmV0Wxyd2Q@mail.gmail.com
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/741f9d741e6dd9bc9174e4f522fc65b87b8d5ee3

Modified Files
--------------
src/backend/access/heap/heapam.c                   |  8 ++-
src/test/modules/injection_points/Makefile         |  3 ++
.../injection_points/expected/repack_decode.out    | 36 +++++++++++++
src/test/modules/injection_points/meson.build      |  1 +
.../injection_points/specs/repack_decode.spec      | 60 ++++++++++++++++++++++
5 files changed, 106 insertions(+), 2 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-09-11 17:22 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-09-11 17:21 pgsql: Fix heap_update() ignoring TABLE_UPDATE_NO_LOGICAL for TOAST tup Masahiko Sawada <msawada@postgresql.org>
2026-09-11 17:22 pgsql: Fix heap_update() ignoring TABLE_UPDATE_NO_LOGICAL for TOAST tup Masahiko Sawada <msawada@postgresql.org>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox