Re: Logical Replication of sequences

Amit Kapila <amit.kapila16@gmail.com>

From: Amit Kapila <amit.kapila16@gmail.com>
To: vignesh C <vignesh21@gmail.com>
Cc: Masahiko Sawada <sawada.mshk@gmail.com>, "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>, shveta malik <shveta.malik@gmail.com>, Nisha Moond <nisha.moond412@gmail.com>, Dilip Kumar <dilipbalaut@gmail.com>, Peter Smith <smithpb2250@gmail.com>, Shlok Kyal <shlok.kyal.oss@gmail.com>, Peter Eisentraut <peter@eisentraut.org>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Euler Taveira <euler@eulerto.com>, Michael Paquier <michael@paquier.xyz>, "Zhijie Hou (Fujitsu)" <houzj.fnst@fujitsu.com>, "Jonathan S. Katz" <jkatz@postgresql.org>
Date: 2025-09-05T11:20:06Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Doc: Add documentation for sequence synchronization.

  2. Remove unused assignment in CREATE PUBLICATION grammar.

  3. Add seq_sync_error_count to subscription statistics.

  4. Fix few issues in commit 5509055d69.

  5. Add sequence synchronization for logical replication.

  6. Add worker type argument to logical replication worker functions.

  7. Introduce "REFRESH SEQUENCES" for subscriptions.

  8. Refactor logical worker synchronization code into a separate file.

  9. Standardize use of REFRESH PUBLICATION in code and messages.

  10. Add "ALL SEQUENCES" support to publications.

  11. Expose sequence page LSN via pg_get_sequence_data.

  12. Resume conflict-relevant data retention automatically.

  13. Post-commit review fixes for 228c370868.

  14. Generate GUC tables from .dat file

On Fri, Sep 5, 2025 at 2:46 PM vignesh C <vignesh21@gmail.com> wrote:
>
> On Fri, 5 Sept 2025 at 04:01, Masahiko Sawada <sawada.mshk@gmail.com> wrote:
> >
> > On Wed, Aug 20, 2025 at 4:57 AM Amit Kapila <amit.kapila16@gmail.com> wrote:
> > >
> > > On Mon, Aug 18, 2025 at 3:36 PM vignesh C <vignesh21@gmail.com> wrote:
> > > >
> > > > Thanks for the comments, the updated version has the changes for the same.
> > > >
> > >
> > > I wanted to first discuss a few design points. The patch implements
> > > "ALTER SUBSCRIPTION ... REFRESH PUBLICATION SEQUENCES" such that it
> > > copies the existing sequences values and also adds/removes any missing
> > > sequences. For the second part (add/remove sequences), we already have
> > > a separate command "ALTER SUBSCRIPTION ... REFRESH PUBLICATION". So, I
> > > feel the new command should only copy the sequence values, as that
> > > will keep the interface easy to define and understand. Additionally,
> > > it will help to simplify the code in the patch, especially in the
> > > function AlterSubscription_refresh.
> >
> > While I agree that the new command just copies the sequence values,
> > I'm not sure the command should be implemented as an extension of
> > ALTER SUBSCRIPTION ... REFRESH PUBLICATION command. Probably what the
> > new command does is quite different from what REFRESH PUBLICATION
> > command does?
>
> Alternatively, the syntax options could be:
> ALTER SUBSCRIPTION subname RESYNC PUBLICATION SEQUENCES;
> or
> ALTER SUBSCRIPTION subname RESYNC SEQUENCES;
>

The other option on these lines is to use SYNC instead of RESYNC as
for users RESYNC sounds more like redo where something has failed and
we are trying to do it again. Also, this will be used even for the
first time sync of sequences. I prefer the first alternative among
these as having the PUBLICATION keyword suggests that we are syncing
the sequences corresponding to all the publications that are part of
subscription but I am okay with the second too.

-- 
With Regards,
Amit Kapila.