diff options
author | Amit Kapila <akapila@postgresql.org> | 2024-01-30 16:31:09 +0530 |
---|---|---|
committer | Amit Kapila <akapila@postgresql.org> | 2024-01-30 16:49:28 +0530 |
commit | 776621a5e4796fa214b6b29a7ca134f6c138572a (patch) | |
tree | ba58dcb69a247bc073eca865879e730c5790ce3a /doc/src | |
parent | b527ebc1d37aa82b771dc9c76111bed1bce35a05 (diff) | |
download | postgresql-776621a5e4796fa214b6b29a7ca134f6c138572a.tar.gz postgresql-776621a5e4796fa214b6b29a7ca134f6c138572a.zip |
Add a failover option to subscriptions.
This commit introduces a new subscription option named 'failover', which
provides users with the ability to set the failover property of the
replication slot on the publisher when creating or altering a
subscription.
This uses the replication commands introduced by commit 7329240437 to
enable the failover option for a logical replication slot.
If the failover option is set to true, the associated replication slots
(i.e. the main slot and the table sync slots) in the upstream database are
enabled to be synchronized to the standbys. Note that the capability to
sync the replication slots will be added in subsequent commits.
Thanks to Masahiko Sawada for the design inputs.
Author: Shveta Malik, Hou Zhijie, Ajin Cherian
Reviewed-by: Peter Smith, Bertrand Drouvot, Dilip Kumar, Masahiko Sawada, Nisha Moond, Kuroda Hayato, Amit Kapila
Discussion: https://postgr.es/m/514f6f2f-6833-4539-39f1-96cd1e011f23@enterprisedb.com
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/catalogs.sgml | 11 | ||||
-rw-r--r-- | doc/src/sgml/ref/alter_subscription.sgml | 25 | ||||
-rw-r--r-- | doc/src/sgml/ref/create_subscription.sgml | 23 | ||||
-rw-r--r-- | doc/src/sgml/ref/pg_dump.sgml | 8 |
4 files changed, 60 insertions, 7 deletions
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index 16b94461b2c..880f717b103 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -8002,6 +8002,17 @@ SCRAM-SHA-256$<replaceable><iteration count></replaceable>:<replaceable>&l <row> <entry role="catalog_table_entry"><para role="column_definition"> + <structfield>subfailover</structfield> <type>bool</type> + </para> + <para> + If true, the associated replication slots (i.e. the main slot and the + table sync slots) in the upstream database are enabled to be + synchronized to the standbys + </para></entry> + </row> + + <row> + <entry role="catalog_table_entry"><para role="column_definition"> <structfield>subconninfo</structfield> <type>text</type> </para> <para> diff --git a/doc/src/sgml/ref/alter_subscription.sgml b/doc/src/sgml/ref/alter_subscription.sgml index 6d36ff0dc90..e9e6d9d74ad 100644 --- a/doc/src/sgml/ref/alter_subscription.sgml +++ b/doc/src/sgml/ref/alter_subscription.sgml @@ -226,10 +226,31 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO < <link linkend="sql-createsubscription-params-with-streaming"><literal>streaming</literal></link>, <link linkend="sql-createsubscription-params-with-disable-on-error"><literal>disable_on_error</literal></link>, <link linkend="sql-createsubscription-params-with-password-required"><literal>password_required</literal></link>, - <link linkend="sql-createsubscription-params-with-run-as-owner"><literal>run_as_owner</literal></link>, and - <link linkend="sql-createsubscription-params-with-origin"><literal>origin</literal></link>. + <link linkend="sql-createsubscription-params-with-run-as-owner"><literal>run_as_owner</literal></link>, + <link linkend="sql-createsubscription-params-with-origin"><literal>origin</literal></link>, and + <link linkend="sql-createsubscription-params-with-failover"><literal>failover</literal></link>. Only a superuser can set <literal>password_required = false</literal>. </para> + + <para> + When altering the + <link linkend="sql-createsubscription-params-with-slot-name"><literal>slot_name</literal></link>, + the <literal>failover</literal> property value of the named slot may differ from the + <link linkend="sql-createsubscription-params-with-failover"><literal>failover</literal></link> + parameter specified in the subscription. When creating the slot, + ensure the slot <literal>failover</literal> property matches the + <link linkend="sql-createsubscription-params-with-failover"><literal>failover</literal></link> + parameter value of the subscription. Otherwise, the slot on the + publisher may behave differently from what subscription's + <link linkend="sql-createsubscription-params-with-failover"><literal>failover</literal></link> + option says. The slot on the publisher could either be + synced to the standbys even when the subscription's + <link linkend="sql-createsubscription-params-with-failover"><literal>failover</literal></link> + option is disabled or could be disabled for sync + even when the subscription's + <link linkend="sql-createsubscription-params-with-failover"><literal>failover</literal></link> + option is enabled. + </para> </listitem> </varlistentry> diff --git a/doc/src/sgml/ref/create_subscription.sgml b/doc/src/sgml/ref/create_subscription.sgml index c7ace922f92..ee89ffb1d12 100644 --- a/doc/src/sgml/ref/create_subscription.sgml +++ b/doc/src/sgml/ref/create_subscription.sgml @@ -117,19 +117,22 @@ CREATE SUBSCRIPTION <replaceable class="parameter">subscription_name</replaceabl command should connect to the publisher at all. The default is <literal>true</literal>. Setting this to <literal>false</literal> will force the values of - <literal>create_slot</literal>, <literal>enabled</literal> and - <literal>copy_data</literal> to <literal>false</literal>. + <literal>create_slot</literal>, <literal>enabled</literal>, + <literal>copy_data</literal>, and <literal>failover</literal> + to <literal>false</literal>. (You cannot combine setting <literal>connect</literal> to <literal>false</literal> with setting <literal>create_slot</literal>, <literal>enabled</literal>, - or <literal>copy_data</literal> to <literal>true</literal>.) + <literal>copy_data</literal>, or <literal>failover</literal> to + <literal>true</literal>.) </para> <para> Since no connection is made when this option is <literal>false</literal>, no tables are subscribed. To initiate replication, you must manually create the replication slot, enable - the subscription, and refresh the subscription. See + the failover if required, enable the subscription, and refresh the + subscription. See <xref linkend="logical-replication-subscription-examples-deferred-slot"/> for examples. </para> @@ -400,6 +403,18 @@ CREATE SUBSCRIPTION <replaceable class="parameter">subscription_name</replaceabl </para> </listitem> </varlistentry> + + <varlistentry id="sql-createsubscription-params-with-failover"> + <term><literal>failover</literal> (<type>boolean</type>)</term> + <listitem> + <para> + Specifies whether the replication slots associated with the subscription + are enabled to be synced to the standbys so that logical + replication can be resumed from the new primary after failover. + The default is <literal>false</literal>. + </para> + </listitem> + </varlistentry> </variablelist></para> </listitem> diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml index 0e5ba4f7125..f8ae4220e1d 100644 --- a/doc/src/sgml/ref/pg_dump.sgml +++ b/doc/src/sgml/ref/pg_dump.sgml @@ -1588,7 +1588,13 @@ CREATE DATABASE foo WITH TEMPLATE template0; dump can be restored without requiring network access to the remote servers. It is then up to the user to reactivate the subscriptions in a suitable way. If the involved hosts have changed, the connection - information might have to be changed. It might also be appropriate to + information might have to be changed. If the subscription needs to + be enabled for + <link linkend="sql-createsubscription-params-with-failover"><literal>failover</literal></link>, + then same needs to be done by executing + <link linkend="sql-altersubscription-params-set"> + <literal>ALTER SUBSCRIPTION ... SET (failover = true)</literal></link> + after the slot has been created. It might also be appropriate to truncate the target tables before initiating a new full table copy. If users intend to copy initial data during refresh they must create the slot with <literal>two_phase = false</literal>. After the initial sync, the |