| From: | Ajin Cherian <itsajin(at)gmail(dot)com> |
|---|---|
| To: | Gyorgy Bolyki <bolyki(at)bolyki(dot)eu>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | 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-03 10:09:19 |
| Message-ID: | CAFPTHDZpoAVoa05y+Bg5xR2gV=TmfQjBx_fEZmusoT0V4pDSpg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
On Thu, Dec 3, 2026 at 6:50 PM Gyorgy Bolyki <bolyki(at)bolyki(dot)eu> wrote:
>
> Hi Ajin,
>
> I will add the patch to the next commitfest as soon as my new community
> account is past its cool-off period.
>
Subject: Re: Logical replication: replicated TRUNCATE crash-loops a
subscriber with a foreign partition lacking TRUNCATE support
Hi György,
Thanks for v2. Before reviewing it in detail, I looked into the code a
bit more and I have second thoughts about my comment 3.
Logical replication in all other cases never writes to foreign tables:
a foreign table as the subscription target is rejected for every
operation, TRUNCATE included, by CheckSubscriptionTargetRel(), and a
foreign partition is rejected for INSERT/UPDATE/DELETE in
apply_handle_tuple_routing() since be541efbfd. TRUNCATE of a foreign
partition is the only path left open, because apply_handle_truncate()
never checks the partitions it gets from find_all_inheritors(). That
looks like a missed case rather than intended behaviour.
So I think apply_handle_truncate() should call
CheckSubscriptionTargetRel() for each partition, as the tuple-routing
code does, instead of consulting GetFdwRoutineForRelation(). This also
refuses TRUNCATE for FDWs that support it, such as postgres_fdw, which
is consistent with INSERT/UPDATE/DELETE but is a behaviour change the
commit message should mention. The truncate_check_rel() call and the
elog(ERROR) in ExecuteTruncateGuts() can stay.
I'm copying Tom, who pushed [1] which blocked logical replication of
DMLon foreign tables, in case he has a view on handling TRUNCATE the
same way.
Regards,
Ajin Cherian
Fujitsu Australia
| From | Date | Subject | |
|---|---|---|---|
| Previous Message | Amit Langote | 2026-12-03 09:05:20 | Re: BUG #19872: JSON_TABLE: an UNUSED PASSING argument's COLLATE leaks into the output columns (wrong results, persi |