Re: Per-table resync for logical replication subscriptions

From: Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>
To: Cagri Biroglu <cagri(dot)biroglu(at)adyen(dot)com>
Cc: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, Ajin Cherian <itsajin(at)gmail(dot)com>, "smithpb2250(at)gmail(dot)com" <smithpb2250(at)gmail(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Subject: Re: Per-table resync for logical replication subscriptions
Date: 2026-11-03 09:54:13
Message-ID: CANhcyEWG6DsUudBSnj7Swsf+sJXioDgAphtHXFvgimqXJ+q2SQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 2 Nov 2026 at 01:35, Cagri Biroglu <cagri(dot)biroglu(at)adyen(dot)com> wrote:
>
> Hi Shlok ,
>
> thank you , fixed in v13, attached.
>
Hi Cagri,

I further reviewed the v13 patch and found that ALTER SUBSCRIPTION ...
REFRESH TABLE truncates the target table by calling
ExecuteTruncateGuts(). Consequently, it executes BEFORE TRUNCATE and
AFTER TRUNCATE statement-level triggers on that table.
For example we have trigger:
CREATE TRIGGER t1_truncate_trigger
AFTER TRUNCATE ON t1
FOR EACH STATEMENT EXECUTE FUNCTION log_t1_trigger();

And if t1 is part of subscription sub1, 'ALTER SUBSCRIPTION sub1
REFRESH TABLE t1;' can call the above trigger.

Is this ok to allow triggers to be called when ALTER SUBSCRIPTION ...
REFRESH TABLE executed?

I checked if any other ALTER SUBSCRIPTION command can execute any
triggers but I did not find any.
I noticed that apply workers can execute row-level INSERT, UPDATE, and
DELETE triggers, and statement-level TRUNCATE triggers, but only when
the table is configured as ENABLE REPLICA or ENABLE ALWAYS.
Should we have a similar way for the REFRESH TABLE case as well?

Thanks,
Shlok Kyal

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Henson Choi 2026-11-03 09:55:49 Re: Add wait events for server logging destination writes
Previous Message shveta malik 2026-11-03 09:47:21 Re: Proposal: Conflict log history table for Logical Replication