Re: Logical replication: replicated TRUNCATE crash-loops a subscriber with a foreign partition lacking TRUNCATE support

From: Gyorgy Bolyki <bolyki(at)bolyki(dot)eu>
To: Ajin Cherian <itsajin(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Logical replication: replicated TRUNCATE crash-loops a subscriber with a foreign partition lacking TRUNCATE support
Date: 2026-12-04 08:52:10
Message-ID: CADaX-_YZWi7ZjLCC=9FRWC8NHx8b8CyqV-osWMnq-4BMTBA7VQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Ajin,

On Thu, 3 Dec 2026 at 10:09, Ajin Cherian <itsajin(at)gmail(dot)com> wrote:
> So I think apply_handle_truncate() should call
> CheckSubscriptionTargetRel() for each partition, as the tuple-routing
> code does

Agreed. v3 is attached, on master 7d3351719bd2. It supersedes v2,
which is still held in list moderation.

apply_handle_truncate() now calls CheckSubscriptionTargetRel() for each
partition. The truncate_check_rel() calls and the run-time check in
ExecuteTruncateGuts() stay. Behaviour change: a replicated TRUNCATE no
longer empties a foreign partition whose FDW supports TRUNCATE, such as
postgres_fdw; it fails like any other change to that partition.

Tested on Ubuntu 24.04 x86_64 with --enable-cassert, master and REL_19
to REL_15: the new case in 013_partition.pl fails without the fix and
passes with it, and the subscription suite passes. REL_18 to REL_15
need their own versions, attached as .txt. A hand run with a
postgres_fdw partition lost the remote rows on master and kept them
with v3.

If back branches should keep today's behaviour, v2's narrower check is
easy to restore there.

Regards,
György Bolyki

Attachment Content-Type Size
v3-0001-Reject-foreign-partitions-in-replicated-TRUNCATE-REL_15.patch.txt text/plain 9.9 KB
v3-0001-Reject-foreign-partitions-in-replicated-TRUNCATE-REL_16.patch.txt text/plain 9.9 KB
v3-0001-Reject-foreign-partitions-in-replicated-TRUNCATE.patch application/x-patch 10.0 KB
v3-0001-Reject-foreign-partitions-in-replicated-TRUNCATE-REL_17.patch.txt text/plain 9.9 KB
v3-0001-Reject-foreign-partitions-in-replicated-TRUNCATE-REL_18.patch.txt text/plain 9.9 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message ZhangChi 2026-12-04 08:58:46 Re: BUG #19977: constraint_exclusion Silently Returns 0 Rows on Subpartitioned Table
Previous Message PG Bug reporting form 2026-12-04 08:39:43 BUG #19976: Internal planner error: ERROR: XX000: too late to create a new PlaceHolderInfo