Skip to content

Commit e66d61c

Browse files
author
Commitfest Bot
committed
[CF 5111] v20251111 - Synchronization of sequences to subscriber
This branch was automatically generated by a robot using patches from an email thread registered at: https://commitfest.postgresql.org/patch/5111 The branch will be overwritten each time a new patch version is posted to the thread, and also periodically to check for bitrot caused by changes on the master branch. Patch(es): https://www.postgresql.org/message-id/CALDaNm0zHQaUpXRtXKR90esaR9o180ejxzQ=+_R=LSmyrDu52Q@mail.gmail.com Author(s): vigneshwaran C
2 parents d2f24df + 3b63424 commit e66d61c

File tree

7 files changed

+357
-49
lines changed

7 files changed

+357
-49
lines changed

doc/src/sgml/catalogs.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6568,7 +6568,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
65686568
(references <link linkend="catalog-pg-class"><structname>pg_class</structname></link>.<structfield>oid</structfield>)
65696569
</para>
65706570
<para>
6571-
Reference to relation
6571+
Reference to table or sequence
65726572
</para></entry>
65736573
</row>
65746574

doc/src/sgml/config.sgml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5198,9 +5198,9 @@ ANY <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="
51985198
is taken into account.
51995199
</para>
52005200
<para>
5201-
In logical replication, this parameter also limits how often a failing
5202-
replication apply worker or table synchronization worker will be
5203-
respawned.
5201+
In logical replication, this parameter also limits how quickly a
5202+
failing replication apply worker or table/sequence synchronization
5203+
worker will be respawned.
52045204
</para>
52055205
</listitem>
52065206
</varlistentry>
@@ -5341,8 +5341,8 @@ ANY <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="
53415341
<listitem>
53425342
<para>
53435343
Specifies maximum number of logical replication workers. This includes
5344-
leader apply workers, parallel apply workers, and table synchronization
5345-
workers.
5344+
leader apply workers, parallel apply workers, and table/sequence
5345+
synchronization workers.
53465346
</para>
53475347
<para>
53485348
Logical replication workers are taken from the pool defined by
@@ -5365,10 +5365,14 @@ ANY <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="
53655365
<para>
53665366
Maximum number of synchronization workers per subscription. This
53675367
parameter controls the amount of parallelism of the initial data copy
5368-
during the subscription initialization or when new tables are added.
5368+
for tables during the subscription initialization or when new tables
5369+
are added. One additional worker is also needed for sequence
5370+
synchronization.
53695371
</para>
53705372
<para>
5371-
Currently, there can be only one synchronization worker per table.
5373+
Currently, there can be only one table synchronization worker per table
5374+
and one sequence synchronization worker to synchronize per
5375+
subscription.
53725376
</para>
53735377
<para>
53745378
The synchronization workers are taken from the pool defined by

doc/src/sgml/func/func-sequence.sgml

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@
6767
</para>
6868
<para>
6969
Sets the sequence object's current value, and optionally
70-
its <literal>is_called</literal> flag. The two-parameter
71-
form sets the sequence's <literal>last_value</literal> field to the
72-
specified value and sets its <literal>is_called</literal> field to
73-
<literal>true</literal>, meaning that the next
70+
its <structfield>is_called</structfield> flag. The two-parameter
71+
form sets the sequence's <structfield>last_value</structfield> field to
72+
the specified value and sets its <structfield>is_called</structfield>
73+
field to <literal>true</literal>, meaning that the next
7474
<function>nextval</function> will advance the sequence before
7575
returning a value. The value that will be reported
7676
by <function>currval</function> is also set to the specified value.
77-
In the three-parameter form, <literal>is_called</literal> can be set
78-
to either <literal>true</literal>
77+
In the three-parameter form, <structfield>is_called</structfield> can
78+
be set to either <literal>true</literal>
7979
or <literal>false</literal>. <literal>true</literal> has the same
8080
effect as the two-parameter form. If it is set
8181
to <literal>false</literal>, the next <function>nextval</function>
@@ -143,6 +143,33 @@ SELECT setval('myseq', 42, false); <lineannotation>Next <function>nextval</fu
143143
or <literal>SELECT</literal> privilege on the last used sequence.
144144
</para></entry>
145145
</row>
146+
147+
<row>
148+
<entry role="func_table_entry" id="func-pg-get-sequence-data"><para role="func_signature">
149+
<indexterm>
150+
<primary>pg_get_sequence_data</primary>
151+
</indexterm>
152+
<function>pg_get_sequence_data</function> ( <type>regclass</type> )
153+
<returnvalue>record</returnvalue>
154+
( <parameter>last_value</parameter> <type>bigint</type>,
155+
<parameter>is_called</parameter> <type>bool</type>,
156+
<parameter>page_lsn</parameter> <type>pg_lsn</type> )
157+
</para>
158+
<para>
159+
Returns information about the sequence.
160+
<structfield>last_value</structfield> is primarily intended for
161+
internal use by pg_dump and by logical replication to synchronize
162+
sequences. <structfield>is_called</structfield> indicates whether the
163+
sequence has been used. Logical replication's sequence synchronization
164+
updates the subscriber's sequence values to match the publisher's.
165+
<structfield>page_lsn</structfield> is the LSN corresponding to the
166+
most recent WAL record that modified this sequence relation.
167+
</para>
168+
<para>
169+
This function requires <literal>USAGE</literal>
170+
or <literal>SELECT</literal> privilege on the sequence.
171+
</para></entry>
172+
</row>
146173
</tbody>
147174
</tgroup>
148175
</table>

0 commit comments

Comments
 (0)