From: | shveta malik <shveta(dot)malik(at)gmail(dot)com> |
---|---|
To: | vignesh C <vignesh21(at)gmail(dot)com> |
Cc: | "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>, Masahiko Sawada <sawada(dot)mshk(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-06 10:59:39 |
Message-ID: | CAJpy0uC+5bt+rtsmrJzX62JOpFeJGKzNWVpgJkBX=dCWRvRocw@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Aug 6, 2025 at 2:28 PM vignesh C <vignesh21(at)gmail(dot)com> wrote:
>
> The attached v20250806 version patch has the changes for the same.
>
Thank You for the patches. Please find a few comments:
1)
* If 'resync_all_sequences' is false:
* Add or remove tables and sequences that have been added to or removed
* from the publication since the last subscription creation or refresh.
* If 'resync_all_sequences' is true:
* Perform the above operation only for sequences.
Shall we update:
Perform the above operation only for sequences and resync all the
sequences including existing ones.
2)
XLogRecPtr srsublsn BKI_FORCE_NULL; /* remote LSN of the
state change
Shall we rename it to srremotelsn or srremlsn? srsublsn gives a
feeling that it is local lsn and should be in sync with the one
displayed by pg_get_sequence_data() locally but that is not the case.
3)
create sequence myseq1 start 1 increment 100;
postgres=# select last_value, is_called, log_cnt, page_lsn from
pg_get_sequence_data('myseq1');
last_value | is_called | log_cnt | page_lsn
------------+-----------+---------+------------
1 | f | 0 | 0/017BEF10
postgres=# select sequencename, last_value from pg_sequences;
sequencename | last_value
--------------+------------
myseq1 |
For a fresh sequence created, last_value shown by pg_get_sequence_data
seems wrong. On doging nextval for the first time, last_value shown by
pg_get_sequence_data does not change as the original value was wrong
itself to start with.
4)
+ Returns information about the sequence. <literal>last_value</literal>
+ is the current value of the sequence, <literal>is_called</literal>
It looks odd to say that 'last_value is the current value of the
sequence'. Why don't we name it curr_val? If this is an existing
function and thus we do not want to change the name, then we can say
something on the line that 'last sequence value set in sequence by
nextval or setval' or something
similar to what pg_sequences says for last_value.
5)
+ and <literal>page_lsn</literal> is the page LSN of the sequence
+ relation.
Is the page_lsn the page lsn of sequence relation or lsn of the last
WAL record written (or in simpler terms that particular record's
page_lsn)? If it is relation page-lsn, it should not change.
6)
I have noticed that when I do nextval, logcnt reduces and page_lsn is
not changed until it crosses the threshold. This is in context of
output returned by pg_get_sequence_data. But on doing setval, page_lsn
changes everytime and logcnt is reset to 0. Is this expected behaviour
or the issue in output of pg_get_sequence_data()? I did not get this
information from setval's doc. Can you please review and confirm?
postgres=# SELECT nextval('myseq2');
nextval
---------
155
postgres=# select last_value, is_called, log_cnt, page_lsn from
pg_get_sequence_data('myseq2');
last_value | is_called | log_cnt | page_lsn
------------+-----------+---------+------------
155 | t | 28 | 0/017C4498
postgres=# SELECT nextval('myseq2');
nextval
---------
175
postgres=# select last_value, is_called, log_cnt, page_lsn from
pg_get_sequence_data('myseq2');
last_value | is_called | log_cnt | page_lsn
------------+-----------+---------+------------
175 | t | 27 | 0/017C4498
postgres=# SELECT setval('myseq2', 55, true);
setval
--------
55
postgres=# select last_value, is_called, log_cnt, page_lsn from
pg_get_sequence_data('myseq2');
last_value | is_called | log_cnt | page_lsn
------------+-----------+---------+------------
55 | t | 0 | 0/017C4568
thanks
Shveta
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2025-08-06 11:07:25 | Re: date_trunc invalid units with infinite value |
Previous Message | Álvaro Herrera | 2025-08-06 10:44:13 | Re: LISTEN/NOTIFY bug: VACUUM sets frozenxid past a xid in async queue |