Re: Logical Replication of sequences - Mailing list pgsql-hackers

From vignesh C
Subject Re: Logical Replication of sequences
Date
Msg-id CALDaNm3GXa-kKTe3oqmKA8oniHvZfgYUXG8mVczv4GJzFwG7bg@mail.gmail.com
Whole thread Raw
In response to Re: Logical Replication of sequences  (Peter Smith <smithpb2250@gmail.com>)
List pgsql-hackers
On Fri, 9 May 2025 at 14:28, shveta malik <shveta.malik@gmail.com> wrote:
>
> On Sat, May 3, 2025 at 7:27 PM vignesh C <vignesh21@gmail.com> wrote:
> >
> > >
> > > Thanks for the comments, the updated patch has the changes for the same.
> >
>
> Thanks for the patches. Please find few comments:
>
>
> 1)
> patch004 commit msg:
> - Drop published sequences are removed from pg_subscription_rel.
>
> Drop -->Dropped

Modified

> 2)
> copy_sequences:
>
> LOG:  Executing query :SELECT s.schname, s.seqname, ps.*, seq.seqtypid,
>        seq.seqstart, seq.seqincrement, seq.seqmin,
>        seq.seqmax, seq.seqcycle
> FROM ( VALUES ('public', 'myseq1'), ('public', 'myseq3') ) AS s
> (schname, seqname)
> JOIN LATERAL pg_sequence_state(s.schname, s.seqname) ps ON true
> ....
>
> Do we really need to log this query? If so, shall it be DEBUG1/DEBUG2?

This is not required, removed it

> 3)
> In log, we get:
>
> ------------------
> LOG:  logical replication synchronized 9 of 9 sequences for subscription "sub1"
> WARNING:  parameters differ for the remote and local sequences
> ("public.myseq1", "public.myseq3") for subscription "sub1"
>
> LOG:  logical replication synchronized 2 of 2 sequences for subscription "sub1"
> WARNING:  parameters differ for the remote and local sequences
> ("public.myseq1", "public.myseq3") for subscription "sub1"
> ------------------
>
> This is confusing. I have 9 sequences, out of which 2 are mismatched.
> So on REFRESH I get the first message as 'synchronized 9 of 9' and
> later when it attempts to resynchronize pending ones automatically, it
> keeps on displaying  'synchronized 2 of 2'.
>
> Can we mention something like below:
> -----------------
> Unsynchronized sequences: 9, attempted in this batch: 9, succedded: 7,
> mismatched/failed:2
>
> So that if it is more than 100, say 120, it will say:
> Unsynchronized sequences: 120, attempted in this batch: 100,
> succedded: 98, mismatched/failed:2
> And in next batch:
> Unsynchronized sequences: 120, attempted in this batch: 20, succedded:
> 20, mismatched:0
>
> And while attempting to synchronize failed ones, it will say:
> Unsynchronized sequences: 2, attempted in this batch: 2, succedded: 0,
> mismatched:2
> -----------------
>
> Please feel free to change the words. The intent is to get a clear
> picture on what is happening.

Fixed this

> 4)
> Why in patch001, we have 'pg_sequence_state' with one argument while
> in 4ht patch it is changed to 2 args? Is it intentional to have it the
> current way in patch001?

This should have been in 001 itself, moved these changes to 001 patch

> 5)
> Section1:
>   <para>
>    A new <firstterm>sequence synchronization worker</firstterm> will be started
>    after executing any of the above subscriber commands, and will exit once the
>    sequences are synchronized.
>   </para>
>
> Section2:
>   <sect2 id="sequence-definition-mismatches">
>    <title>Sequence Definition Mismatches</title>
>    <warning>
>     <para>
>      During sequence synchronization, the sequence definitions of the publisher
>      and the subscriber are compared. A WARNING is logged if any differences
>      are detected.
>     </para>
>    </warning>
>
>
> None of the section mentions that the synchronization worker will keep
> on attempting to synchronize the failed/mismtached sequences until the
> differences are resolved (provided disable_on_error is not enabled).
> I think we can mention such a thing briefly in
> 'sequence-definition-mismatches' section.

Modified

The attached v20250514 version patch has the changes for the same.

Regards,
Vignesh

Attachment

pgsql-hackers by date:

Previous
From: Nisha Moond
Date:
Subject: Re: Logical Replication of sequences
Next
From: vignesh C
Date:
Subject: Re: Logical Replication of sequences