Re: Logical Replication of sequences

vignesh C <vignesh21@gmail.com>

From: vignesh C <vignesh21@gmail.com>
To: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: shveta malik <shveta.malik@gmail.com>, Peter Smith <smithpb2250@gmail.com>, Shlok Kyal <shlok.kyal.oss@gmail.com>, Amit Kapila <amit.kapila16@gmail.com>, Peter Eisentraut <peter@eisentraut.org>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Tomas Vondra <tomas.vondra@enterprisedb.com>, Euler Taveira <euler@eulerto.com>, Michael Paquier <michael@paquier.xyz>, "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>, Hou, Zhijie/侯 志杰 <houzj.fnst@fujitsu.com>, "Jonathan S. Katz" <jkatz@postgresql.org>
Date: 2024-11-18T10:19:33Z
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

Attachments

On Thu, 31 Oct 2024 at 14:57, vignesh C <vignesh21@gmail.com> wrote:
>
> On Thu, 24 Oct 2024 at 04:24, Masahiko Sawada <sawada.mshk@gmail.com> wrote:
> >
> > Here are comments on the 0001 and 0002 patches:
> >
> > 0001 patch:
> >
> > read_seq_tuple() reads a buffer and acquires a lock on it, and the
> > buffer is returned to the caller while being locked. So I think it's
> > possible for the caller to get the page LSN even without changes.
> > Since pg_sequence_state() is the sole caller that requests lsn_ret to
> > be set, I think the changes of read_seq_tuples() is not necessarily
> > necessary.
>
> Modified
>
> > 0002 patch:
> > +        Assert(all_tables && *all_tables == false);
> > +        Assert(all_sequences && *all_sequences == false);
> >
> > I think it's better to set both *all_tables and *all_sequence to false
> > at the beginning of the function to ensure this function works as
> > expected regardless of their initial values.
>
> Modified
>
> > ---
> >         appendPQExpBufferStr(query,
> >                              "SELECT p.tableoid, p.oid, p.pubname, "
> >                              "p.pubowner, "
> > -                            "p.puballtables, p.pubinsert,
> > p.pubupdate, p.pubdelete, p.pubtruncate, p.pubviaroot "
> > +                            "p.puballtables, false as
> > p.puballsequences, p.pubinsert, p.pubupdate, p.pubdelete,
> > p.pubtruncate, p.pubviaroot "
> >                              "FROM pg_publication p");
> >     else if (fout->remoteVersion >= 110000)
> >         appendPQExpBufferStr(query,
> >                              "SELECT p.tableoid, p.oid, p.pubname, "
> >                              "p.pubowner, "
> > -                            "p.puballtables, p.pubinsert,
> > p.pubupdate, p.pubdelete, p.pubtruncate, false AS pubviaroot "
> > +                            "p.puballtables, false as
> > p.puballsequences, p.pubinsert, p.pubupdate, p.pubdelete,
> > p.pubtruncate, false AS pubviaroot "
> >                              "FROM pg_publication p");
> >     else
> >         appendPQExpBufferStr(query,
> >                              "SELECT p.tableoid, p.oid, p.pubname, "
> >                              "p.pubowner, "
> > -                            "p.puballtables, p.pubinsert,
> > p.pubupdate, p.pubdelete, false AS pubtruncate, false AS pubviaroot "
> > +                            "p.puballtables, false as
> > p.puballsequences, p.pubinsert, p.pubupdate, p.pubdelete, false AS
> > pubtruncate, false AS pubviaroot "
> >                              "FROM pg_publication p");
> >
> > The column name should be puballsequences, not p.puballsequences.
>
> Modified
>
> > ---
> > IIUC the changes of describeOneTableDetails() includes two kinds of
> > changes: refactoring to use printTable() instead of printQuery(), and
> > adding publications that includes the sequence. Is the first
> > refactoring necessary for the second change? If not, should it be done
> > in a separate patch?
>
> We are adding publication titles as footers to the sequence
> description, each with different publication names. Since the number
> of publications is unknown in advance, we will first determine the
> total number of publications, then allocate the necessary size for the
> footers. We will append footers[0] with either 'Owned by' or 'Sequence
> for identity column,' followed by the publication titles.
> Additionally, these will be subject to version checks. In this case,
> using printTable instead of printQuery is preferable, as it simplifies
> the code.
>
> The attached patch has the changes for the fixes.

The patch needed to be rebased; here is the updated version.

Regards,
Vignesh