diff options
| author | Amit Kapila <akapila@postgresql.org> | 2022-03-14 09:32:40 +0530 |
|---|---|---|
| committer | Amit Kapila <akapila@postgresql.org> | 2022-03-14 09:32:40 +0530 |
| commit | 705e20f8550c0e8e47c0b6b20b5f5ffd6ffd9e33 (patch) | |
| tree | d6606b7864bdcc3439caaeccfc0dc3a31a9386e3 /doc/src | |
| parent | 369398ed886dc13956654777467536625e6fc7ee (diff) | |
Optionally disable subscriptions on error.
Logical replication apply workers for a subscription can easily get stuck
in an infinite loop of attempting to apply a change, triggering an error
(such as a constraint violation), exiting with the error written to the
subscription server log, and restarting.
To partially remedy the situation, this patch adds a new subscription
option named 'disable_on_error'. To be consistent with old behavior, this
option defaults to false. When true, both the tablesync worker and apply
worker catch any errors thrown and disable the subscription in order to
break the loop. The error is still also written in the logs.
Once the subscription is disabled, users can either manually resolve the
conflict/error or skip the conflicting transaction by using
pg_replication_origin_advance() function. After resolving the conflict,
users need to enable the subscription to allow apply process to proceed.
Author: Osumi Takamichi and Mark Dilger
Reviewed-by: Greg Nancarrow, Vignesh C, Amit Kapila, Wang wei, Tang Haiying, Peter Smith, Masahiko Sawada, Shi Yu
Discussion : https://postgr.es/m/DB35438F-9356-4841-89A0-412709EBD3AB%40enterprisedb.com
Diffstat (limited to 'doc/src')
| -rw-r--r-- | doc/src/sgml/catalogs.sgml | 10 | ||||
| -rw-r--r-- | doc/src/sgml/logical-replication.sgml | 5 | ||||
| -rw-r--r-- | doc/src/sgml/ref/alter_subscription.sgml | 4 | ||||
| -rw-r--r-- | doc/src/sgml/ref/create_subscription.sgml | 12 |
4 files changed, 27 insertions, 4 deletions
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index 83987a99045..7777d605142 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -7771,6 +7771,16 @@ SCRAM-SHA-256$<replaceable><iteration count></replaceable>:<replaceable>&l <row> <entry role="catalog_table_entry"><para role="column_definition"> + <structfield>subdisableonerr</structfield> <type>bool</type> + </para> + <para> + If true, the subscription will be disabled if one of its workers + detects an error + </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/logical-replication.sgml b/doc/src/sgml/logical-replication.sgml index 82326c39019..6431d4796db 100644 --- a/doc/src/sgml/logical-replication.sgml +++ b/doc/src/sgml/logical-replication.sgml @@ -364,8 +364,9 @@ CONTEXT: processing remote data for replication origin "pg_16395" during "INSER the replication origin name can be found from the server log (LSN 0/14C0378 and replication origin <literal>pg_16395</literal> in the above case). To skip the transaction, the subscription needs to be disabled temporarily by - <command>ALTER SUBSCRIPTION ... DISABLE</command> first. Then, the transaction - can be skipped by calling the + <command>ALTER SUBSCRIPTION ... DISABLE</command> first or alternatively, the + subscription can be used with the <literal>disable_on_error</literal> option. + Then, the transaction can be skipped by calling the <link linkend="pg-replication-origin-advance"> <function>pg_replication_origin_advance()</function></link> function with the <parameter>node_name</parameter> (i.e., <literal>pg_16395</literal>) and the diff --git a/doc/src/sgml/ref/alter_subscription.sgml b/doc/src/sgml/ref/alter_subscription.sgml index 0d6f064f58d..58b78a94eab 100644 --- a/doc/src/sgml/ref/alter_subscription.sgml +++ b/doc/src/sgml/ref/alter_subscription.sgml @@ -204,8 +204,8 @@ ALTER SUBSCRIPTION <replaceable class="parameter">name</replaceable> RENAME TO < information. The parameters that can be altered are <literal>slot_name</literal>, <literal>synchronous_commit</literal>, - <literal>binary</literal>, and - <literal>streaming</literal>. + <literal>binary</literal>, <literal>streaming</literal>, and + <literal>disable_on_error</literal>. </para> </listitem> </varlistentry> diff --git a/doc/src/sgml/ref/create_subscription.sgml b/doc/src/sgml/ref/create_subscription.sgml index e80a2617a34..b701752fc9b 100644 --- a/doc/src/sgml/ref/create_subscription.sgml +++ b/doc/src/sgml/ref/create_subscription.sgml @@ -290,6 +290,18 @@ CREATE SUBSCRIPTION <replaceable class="parameter">subscription_name</replaceabl </listitem> </varlistentry> + + <varlistentry> + <term><literal>disable_on_error</literal> (<type>boolean</type>)</term> + <listitem> + <para> + Specifies whether the subscription should be automatically disabled + if any errors are detected by subscription workers during data + replication from the publisher. The default is + <literal>false</literal>. + </para> + </listitem> + </varlistentry> </variablelist> </para> |
