| From: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
|---|---|
| To: | Cagri Biroglu <cagri(dot)biroglu(at)adyen(dot)com> |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Per-table resync for logical replication subscriptions |
| Date: | 2026-07-09 17:41:38 |
| Message-ID: | CAD21AoD_RKYrzcR377Ptcr4doKnsF-+k80QTPsMwG9oe2O83hg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
On Wed, Jul 8, 2026 at 3:55 AM Cagri Biroglu <cagri(dot)biroglu(at)adyen(dot)com> wrote:
>
> here is the WIP patch for the disabled-subscription case.
> It adds:
>
> ALTER SUBSCRIPTION name REFRESH TABLE table_name
> [ WITH (copy_data = true, truncate = true) ]
>
> The command is subscriber-local: it resets just the named relation in
> pg_subscription_rel back to the initial sync state (optionally
> truncating the local copy first), so a tablesync worker re-copies that
> one table on the next enable, reusing the existing tablesync machinery.
> Publication membership and other tables are left untouched. As
> discussed, this first version requires the subscription to be disabled.
>
> The tests are included in the same patch: a TAP test at
> src/test/subscription/t/039_refresh_table.pl that
>
> - resyncs one drifted table on a two-node setup and confirms it
> matches the publisher again after re-enabling;
> - confirms only the targeted relation is reset (a sibling table is
> left in 'r' state);
> - checks the rejection cases: enabled subscription, table not in the
> subscription, a sequence, truncate without copy_data, and running
> inside a transaction block.
>
> The full src/test/subscription suite and the core regression tests pass
> with the patch applied.
>
> Open questions if this direction makes sense ,I would still like feedback on: the command spelling
> (REFRESH TABLE vs RESYNC TABLE), and whether the enabled-subscription
> case is worth doing as a follow-up (it needs the running apply worker to
> notice and re-read the reset relation state).
REFRESH TABLE is better to me. It's more consistent with the existing
commands such as REFRESH REQUENCES.
I've not looked at the patch in depth yet but I have a few comments:
I think it might be a good idea that the REFRESH TABLE command can
take multiple tables rather than one table.
---
Why does the REFRESH TABLE command require for the subscription to be
disabled while REFRESH PUBLICATIONS doesn't?
Regards,
--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-07-09 18:07:46 | Re: PG20 Minimum Dependency Thread |
| Previous Message | Greg Sabino Mullane | 2026-07-09 17:23:23 | Re: Proposal: new file format for hba/ident/hosts configuration? |