mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
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
This commit is contained in:
@ -8000,6 +8000,17 @@ SCRAM-SHA-256$<replaceable><iteration count></replaceable>:<replaceable>&l
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<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>
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user