From: | vignesh C <vignesh21(at)gmail(dot)com> |
---|---|
To: | Peter Smith <smithpb2250(at)gmail(dot)com> |
Cc: | "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(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> |
Subject: | Re: Logical Replication of sequences |
Date: | 2025-04-28 12:56:56 |
Message-ID: | CALDaNm00Gf-EGFpr__7dioEgotkDm1e75RicRQ-hqCdj_5Yjpw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sat, 26 Apr 2025 at 14:24, Peter Smith <smithpb2250(at)gmail(dot)com> wrote:
>
> Hi Vignesh.
>
> Some review comments for v20250426-0005.
>
> 4b.
> AFAIK, when copy_data=false, then not only will *existing* sequences
> not be synchronised, but even the *new* sequences will not be
> synchronised. Effectively, when copy_data = false, then nothing at all
> happens for sequences as far as what the user sees, right?
>
> Experiment:
>
> test_pub=# create publication pub1 for all sequences;
> CREATE PUBLICATION
>
> test_sub=# create sequence s1;
> CREATE SEQUENCE
> NOTICE: created replication slot "sub1" on publisher
> CREATE SUBSCRIPTION
>
> test_pub=# create sequence s1;
> CREATE SEQUENCE
> test_pub=# select * from nextval('s1');
> nextval
> ---------
> 1
> (1 row)
>
> test_pub=# select * from nextval('s1');
> nextval
> ---------
> 2
> (1 row)
>
> test_pub=# select * from nextval('s1');
> nextval
> ---------
> 3
> (1 row)
>
> test_sub=# alter subscription sub1 refresh publication with (copy_data=false);
> ALTER SUBSCRIPTION
>
> test_sub=# select * from s1;
> last_value | log_cnt | is_called
> ------------+---------+-----------
> 1 | 0 | f
> (1 row)
>
> So, subscriber side s1 is unaffected.
>
> Maybe it is not worth the effort, but doesn't this mean that you could
> optimise the AlterSubscription_refresh() logic to completely skip all
> processing for sequences when copy_data=false. e.g. what's the point
> of gathering publisher sequence lists and setting INIT states for
> them, etc, when it won't synchronise anything because copy_data=false?
> Everything will be synchronised later anyway when the user does
> REFRESH PUBLICATION SEQUENCES.
Currently this is in line with table behavior, I felt let's keep it
that way so that it will be easier to extend sequence replication as
use cases grow and will become more in sync with tables.
The rest of the comments were fixed, the attached v20250428 version
patch has the changes for the same.
Also the issue reported at [1] is available in the attached patch.
[1] - https://www.postgresql.org/message-id/CAHut%2BPujY8Xd%3DT94zuPuF21s0dLRGVJaXgRnLbGE47pwSpo-YA%40mail.gmail.com
Regards,
Vignesh
Attachment | Content-Type | Size |
---|---|---|
v20250428-0003-Reorganize-tablesync-Code-and-Introduce-sy.patch | text/x-patch | 23.0 KB |
v20250428-0005-Documentation-for-sequence-synchronization.patch | text/x-patch | 26.1 KB |
v20250428-0004-Enhance-sequence-synchronization-during-su.patch | text/x-patch | 97.9 KB |
v20250428-0001-Introduce-pg_sequence_state-function-for-e.patch | text/x-patch | 6.7 KB |
v20250428-0002-Introduce-ALL-SEQUENCES-support-for-Postgr.patch | text/x-patch | 106.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2025-04-28 13:14:54 | Re: allow changing autovacuum_max_workers without restarting |
Previous Message | Shlok Kyal | 2025-04-28 12:51:46 | Re: Restrict publishing of partitioned table with a foreign table as partition |