Re: Logical Replication of sequences

From: shveta malik <shveta(dot)malik(at)gmail(dot)com>
To: vignesh C <vignesh21(at)gmail(dot)com>
Cc: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Euler Taveira <euler(at)eulerto(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>, "Jonathan S(dot) Katz" <jkatz(at)postgresql(dot)org>, shveta malik <shveta(dot)malik(at)gmail(dot)com>
Subject: Re: Logical Replication of sequences
Date: 2025-08-26 05:51:05
Message-ID: CAJpy0uC-Jx2L6tOTnDQ_Zwz99X3HQDik6tG=+1a71SxZFiy12w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Aug 21, 2025 at 10:08 PM vignesh C <vignesh21(at)gmail(dot)com> wrote:
>

> I have also addressed all the comments from [1] in the attached
> v20250823 version patch.
> [1] - https://www.postgresql.org/message-id/CAA4eK1%2BoVQW8oP%3DLo1X8qac6dzg-fgGQ6R_F_psfokUEqe%2Ba6w%40mail.gmail.com
>

Thank You for the patches. I see a race condition between alter-seq and refresh.

Say we have triggered REFRESH on sub, and when seq-sync worker is in
copy_sequences() where it has retrieved the local sequence using
seqname while it has not locked the sequence-relation yet, if
meanwhile we alter sequence and change its name, seq-sync worker ends
up syncing that renamed sequence values with old-fetched sequence.
Steps:

1) create a sequence seq0 on pub and sub
2) do REFRESH PUBLICATION SEQ on sub
3) In seq-sync worker, during copy_sequences() hold debugger at:
seqinfo->remote_seq_fetched = true;
4) rename sequence on sub : ALTER SEQUENCE seq0 RENAME TO seq1;
5) release debugger in seq-sync worker. It will end up syncing seq1
using seq0 fetched from pub.

thanks
Shveta

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2025-08-26 06:01:40 Re: Potential problem in commit f777d773878 and 4f7f7b03758
Previous Message Chao Li 2025-08-26 05:26:28 Optimize JsonbContainerTypeName by reordering type checks