1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Add option to modify sync commit per subscription

This also changes default behaviour of subscription workers to
synchronous_commit = off.

Author: Petr Jelinek <petr.jelinek@2ndquadrant.com>
This commit is contained in:
Peter Eisentraut
2017-04-14 13:58:46 -04:00
parent 25371a72b9
commit 887227a1cc
13 changed files with 145 additions and 33 deletions

View File

@ -6530,6 +6530,16 @@
<entry>If true, the subscription is enabled and should be replicating.</entry>
</row>
<row>
<entry><structfield>subsynccommit</structfield></entry>
<entry><type>text</type></entry>
<entry></entry>
<entry>
Contains the value of the <varname>synchronous_commit</varname>
setting for the subscription workers.
</entry>
</row>
<row>
<entry><structfield>subconninfo</structfield></entry>
<entry><type>text</type></entry>

View File

@ -26,6 +26,7 @@ ALTER SUBSCRIPTION <replaceable class="PARAMETER">name</replaceable> WITH ( <rep
<phrase>where <replaceable class="PARAMETER">suboption</replaceable> can be:</phrase>
SLOT NAME = <replaceable class="PARAMETER">slot_name</replaceable>
| SYNCHRONOUS_COMMIT = <replaceable class="PARAMETER">synchronous_commit</replaceable>
ALTER SUBSCRIPTION <replaceable class="PARAMETER">name</replaceable> SET PUBLICATION <replaceable class="PARAMETER">publication_name</replaceable> [, ...] { REFRESH WITH ( <replaceable class="PARAMETER">puboption</replaceable> [, ... ] ) | NOREFRESH }
ALTER SUBSCRIPTION <replaceable class="PARAMETER">name</replaceable> REFRESH PUBLICATION WITH ( <replaceable class="PARAMETER">puboption</replaceable> [, ... ] )
@ -91,6 +92,7 @@ ALTER SUBSCRIPTION <replaceable class="PARAMETER">name</replaceable> DISABLE
<varlistentry>
<term><literal>CONNECTION '<replaceable class="parameter">conninfo</replaceable>'</literal></term>
<term><literal>SLOT NAME = <replaceable class="parameter">slot_name</replaceable></literal></term>
<term><literal>SYNCHRONOUS_COMMIT = <replaceable class="PARAMETER">synchronous_commit</replaceable></literal></term>
<listitem>
<para>
These clauses alter properties originally set by

View File

@ -32,6 +32,7 @@ CREATE SUBSCRIPTION <replaceable class="PARAMETER">subscription_name</replaceabl
| CREATE SLOT | NOCREATE SLOT
| SLOT NAME = <replaceable class="PARAMETER">slot_name</replaceable>
| COPY DATA | NOCOPY DATA
| SYNCHRONOUS_COMMIT = <replaceable class="PARAMETER">synchronous_commit</replaceable>
| NOCONNECT
</synopsis>
</refsynopsisdiv>
@ -147,6 +148,36 @@ CREATE SUBSCRIPTION <replaceable class="PARAMETER">subscription_name</replaceabl
</listitem>
</varlistentry>
<varlistentry>
<term><literal>SYNCHRONOUS_COMMIT = <replaceable class="PARAMETER">synchronous_commit</replaceable></literal></term>
<listitem>
<para>
The value of this parameter overrides the
<xref linkend="guc-synchronous-commit"> setting. The default value is
<literal>off</literal>.
</para>
<para>
It is safe to use <literal>off</literal> for logical replication: If the
subscriber loses transactions because of missing synchronization, the
data will be resent from the publisher.
</para>
<para>
A different setting might be appropriate when doing synchronous logical
replication. The logical replication workers report the positions of
writes and flushes to the publisher, and when using synchronous
replication, the publisher will wait for the actual flush. This means
that setting <literal>SYNCHRONOUS_COMMIT</literal> for the subscriber
to <literal>off</literal> when the subscription is used for synchronous
replication might increase the latency for <command>COMMIT</command> on
the publisher. In this scenario, it can be advantageous to set
<literal>SYNCHRONOUS_COMMIT</literal> to <literal>local</literal> or
higher.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>NOCONNECT</literal></term>
<listitem>