diff options
| author | Amit Kapila <akapila@postgresql.org> | 2025-10-23 08:30:27 +0000 |
|---|---|---|
| committer | Amit Kapila <akapila@postgresql.org> | 2025-10-23 08:30:27 +0000 |
| commit | f0b3573c3aac6c0ea4cbc278f98178516579d370 (patch) | |
| tree | af2caa24d8562050b79ccb302d97437596b4cc55 /doc/src | |
| parent | 6ae08d9583e9a5e951286948bdd9fcd58e67718a (diff) | |
Introduce "REFRESH SEQUENCES" for subscriptions.
This patch adds support for a new SQL command:
ALTER SUBSCRIPTION ... REFRESH SEQUENCES
This command updates the sequence entries present in the
pg_subscription_rel catalog table with the INIT state to trigger
resynchronization.
In addition to the new command, the following subscription commands have
been enhanced to automatically refresh sequence mappings:
ALTER SUBSCRIPTION ... REFRESH PUBLICATION
ALTER SUBSCRIPTION ... ADD PUBLICATION
ALTER SUBSCRIPTION ... DROP PUBLICATION
ALTER SUBSCRIPTION ... SET PUBLICATION
These commands will perform the following actions:
Add newly published sequences that are not yet part of the subscription.
Remove sequences that are no longer included in the publication.
This ensures that sequence replication remains aligned with the current
state of the publication on the publisher side.
Note that the actual synchronization of sequence data/values will be
handled in a subsequent patch that introduces a dedicated sequence sync
worker.
Author: Vignesh C <vignesh21@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: shveta malik <shveta.malik@gmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Nisha Moond <nisha.moond412@gmail.com>
Reviewed-by: Shlok Kyal <shlok.kyal.oss@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Hou Zhijie <houzj.fnst@fujitsu.com>
Discussion: https://postgr.es/m/CAA4eK1LC+KJiAkSrpE_NwvNdidw9F2os7GERUeSxSKv71gXysQ@mail.gmail.com
Diffstat (limited to 'doc/src')
| -rw-r--r-- | doc/src/sgml/catalogs.sgml | 29 | ||||
| -rw-r--r-- | doc/src/sgml/ref/alter_subscription.sgml | 42 |
2 files changed, 55 insertions, 16 deletions
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index 9b3aae8603b..6c8a0f173c9 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -8199,16 +8199,19 @@ SCRAM-SHA-256$<replaceable><iteration count></replaceable>:<replaceable>&l </indexterm> <para> - The catalog <structname>pg_subscription_rel</structname> contains the - state for each replicated relation in each subscription. This is a - many-to-many mapping. + The catalog <structname>pg_subscription_rel</structname> stores the + state of each replicated table and sequence for each subscription. This + is a many-to-many mapping. </para> <para> - This catalog only contains tables known to the subscription after running - either <link linkend="sql-createsubscription"><command>CREATE SUBSCRIPTION</command></link> or - <link linkend="sql-altersubscription"><command>ALTER SUBSCRIPTION ... REFRESH - PUBLICATION</command></link>. + This catalog contains tables and sequences known to the subscription + after running: + <link linkend="sql-createsubscription"><command>CREATE SUBSCRIPTION</command></link>, + <link linkend="sql-altersubscription-params-refresh-publication"> + <command>ALTER SUBSCRIPTION ... REFRESH PUBLICATION</command></link>, or + <link linkend="sql-altersubscription-params-refresh-sequences"> + <command>ALTER SUBSCRIPTION ... REFRESH SEQUENCES</command></link>. </para> <table> @@ -8242,7 +8245,7 @@ SCRAM-SHA-256$<replaceable><iteration count></replaceable>:<replaceable>&l (references <link linkend="catalog-pg-class"><structname>pg_class</structname></link>.<structfield>oid</structfield>) </para> <para> - Reference to relation + Reference to table or sequence </para></entry> </row> @@ -8251,12 +8254,20 @@ SCRAM-SHA-256$<replaceable><iteration count></replaceable>:<replaceable>&l <structfield>srsubstate</structfield> <type>char</type> </para> <para> - State code: + State code for the table or sequence. + </para> + <para> + State codes for tables: <literal>i</literal> = initialize, <literal>d</literal> = data is being copied, <literal>f</literal> = finished table copy, <literal>s</literal> = synchronized, <literal>r</literal> = ready (normal replication) + </para> + <para> + State codes for sequences: + <literal>i</literal> = initialize, + <literal>r</literal> = ready </para></entry> </row> diff --git a/doc/src/sgml/ref/alter_subscription.sgml b/doc/src/sgml/ref/alter_subscription.sgml index 12f72ba3167..8ab3b7fbd37 100644 --- a/doc/src/sgml/ref/alter_subscription.sgml +++ b/doc/src/sgml/ref/alter_subscription.sgml @@ -26,6 +26,7 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> SET PUBLICA ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> ADD PUBLICATION <replaceable class="parameter">publication_name</replaceable> [, ...] [ WITH ( <replaceable class="parameter">publication_option</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) ] ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> DROP PUBLICATION <replaceable class="parameter">publication_name</replaceable> [, ...] [ WITH ( <replaceable class="parameter">publication_option</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) ] ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> REFRESH PUBLICATION [ WITH ( <replaceable class="parameter">refresh_option</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) ] +ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> REFRESH SEQUENCES ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> ENABLE ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> DISABLE ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> SET ( <replaceable class="parameter">subscription_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) @@ -139,9 +140,10 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO < <term><literal>refresh</literal> (<type>boolean</type>)</term> <listitem> <para> - When false, the command will not try to refresh table information. - <literal>REFRESH PUBLICATION</literal> should then be executed separately. - The default is <literal>true</literal>. + When <literal>false</literal>, the command will not try to refresh + table and sequence information. <literal>REFRESH PUBLICATION</literal> + should then be executed separately. The default is + <literal>true</literal>. </para> </listitem> </varlistentry> @@ -158,7 +160,7 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO < <term><literal>REFRESH PUBLICATION</literal></term> <listitem> <para> - Fetch missing table information from publisher. This will start + Fetch missing table and sequence information from the publisher. This will start replication of tables that were added to the subscribed-to publications since <link linkend="sql-createsubscription"> <command>CREATE SUBSCRIPTION</command></link> or @@ -166,6 +168,12 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO < </para> <para> + The system catalog <link linkend="catalog-pg-subscription-rel">pg_subscription_rel</link> + is updated to record all tables and sequences known to the subscription, + that are still part of the publication. + </para> + + <para> <replaceable>refresh_option</replaceable> specifies additional options for the refresh operation. The supported options are: @@ -174,15 +182,20 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO < <term><literal>copy_data</literal> (<type>boolean</type>)</term> <listitem> <para> - Specifies whether to copy pre-existing data in the publications - that are being subscribed to when the replication starts. - The default is <literal>true</literal>. + Specifies whether to copy pre-existing data for tables and synchronize + sequences in the publications that are being subscribed to when the replication + starts. The default is <literal>true</literal>. </para> <para> Previously subscribed tables are not copied, even if a table's row filter <literal>WHERE</literal> clause has since been modified. </para> <para> + Previously subscribed sequences are not re-synchronized. To do that, + use <link linkend="sql-altersubscription-params-refresh-sequences"> + <command>ALTER SUBSCRIPTION ... REFRESH SEQUENCES</command></link>. + </para> + <para> See <xref linkend="sql-createsubscription-notes"/> for details of how <literal>copy_data = true</literal> can interact with the <link linkend="sql-createsubscription-params-with-origin"><literal>origin</literal></link> @@ -200,6 +213,21 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO < </listitem> </varlistentry> + <varlistentry id="sql-altersubscription-params-refresh-sequences"> + <term><literal>REFRESH SEQUENCES</literal></term> + <listitem> + <para> + Re-synchronize sequence data with the publisher. Unlike + <link linkend="sql-altersubscription-params-refresh-publication"> + <command>ALTER SUBSCRIPTION ... REFRESH PUBLICATION</command></link> which + only has the ability to synchronize newly added sequences, + <literal>REFRESH SEQUENCES</literal> will re-synchronize the sequence + data for all currently subscribed sequences. It does not add or remove + sequences from the subscription to match the publication. + </para> + </listitem> + </varlistentry> + <varlistentry id="sql-altersubscription-params-enable"> <term><literal>ENABLE</literal></term> <listitem> |
