Wiki / Configuration Parameters
synchronous_standby_names
Specifies a list of standby servers that can support synchronous replication, as described in Section 26.2.8. There will be one or more active synchronous standbys; transactions waiting for commit will be allowed to proceed after these standby servers confirm receipt of their data. The synchronous standbys will be those whose names appear in this list, and that are both currently connected and streaming data in real-time (as shown by a state of streaming in the pg_stat_replication view). Specifying more than one synchronous standby can allow for very high availability and protection against data loss. The name of a standby server for this purpose is the application_name setting of the standby, as set in the standby's connection information. In case of a physical replication standby, this should be set in the primary_conninfo setting; the default is the setting of cluster_name if set, else walreceiver. For logical replication, this can be set in the connection information of the subscription, and it defaults to the subscription name. For other replication stream consumers, consult their documentation. This parameter specifies a list of standby servers using either of the following syntaxes: [FIRST] num_sync ( standby_name [, ...] ) ANY num_sync ( standby_name [, ...] ) standby_name [, ...] where num_sync is the number of synchronous standbys that transactions need to wait for replies from, and standby_name is the name of a standby server. num_sync must be an integer value greater than zero. FIRST and ANY specify the method to choose synchronous standbys from the listed servers. The keyword FIRST, coupled with num_sync, specifies a priority-based synchronous replication and makes transaction commits wait until their WAL records are replicated to num_sync synchronous standbys chosen based on their priorities. For example, a setting of FIRST 3 (s1, s2, s3, s4) will cause each commit to wait for replies from three higher-priority standbys chosen from standby servers s1, s2, s3 and s4. The standbys whose names appear earlier in the list are given higher priority and will be considered as synchronous. Other standby servers appearing later in this list represent potential synchronous standbys. If any of the current synchronous standbys disconnects for whatever reason, it will be replaced immediately with the next-highest-priority standby. The keyword FIRST is optional. The keyword ANY, coupled with num_sync, specifies a quorum-based synchronous replication and makes transaction commits wait until their WAL records are replicated to at least num_sync listed standbys. For example, a setting of ANY 3 (s1, s2, s3, s4) will cause each commit to proceed as soon as at least any three standbys of s1, s2, s3 and s4 reply. FIRST and ANY are case-insensitive. If these keywords are used as the name of a standby server, its standby_name must be double-quoted. The third syntax was used before PostgreSQL version 9.6 and is still supported. It's the same as the first syntax with FIRST and num_sync equal to 1. For example, FIRST 1 (s1, s2) and s1, s2 have the same meaning: either s1 or s2 is chosen as a synchronous standby. The special entry * matches any standby name. There is no mechanism to enforce uniqueness of standby names. In case of duplicates one of the matching standbys will be considered as higher priority, though exactly which one is indeterminate. Note Each standby_name should have the form of a valid SQL identifier, unless it is *. You can use double-quoting if necessary. But note that standby_names are compared to standby application names case-insensitively, whether double-quoted or not. If no synchronous standby names are specified here, then synchronous replication is not enabled and transaction commits will not wait for replication. This is the default configuration. Even when synchronous replication is enabled, individual transactions can be configured not to wait for replication by setting the synchronous_commit parameter to local or off. This parameter can only be set in the postgresql.conf file or on the server command line.
English manual coverage begins with PostgreSQL 7.4. Source history and runtime observations have their own recorded version boundaries.
Reading PG 18·Select a recorded version
- boot val
- Unknown
- category
- Replication / Primary Server
- context
- sighup
- doc same as
- Unknown
- documented
- true
- enumvals
- Unknown
- extra desc
- Unknown
- lang
- en
- max val
- Unknown
- metadata version
- 18
- min val
- Unknown
- name
- synchronous_standby_names
- short desc
- Number of synchronous standbys and list of names of potential synchronous ones.
- source
- pg-settings-source-snapshot
- unit
- Unknown
- vartype
- string
Definition PG 18
Specifies a list of standby servers that can support
synchronous replication, as described in
Section 26.2.8.
There will be one or more active synchronous standbys;
transactions waiting for commit will be allowed to proceed after
these standby servers confirm receipt of their data.
The synchronous standbys will be those whose names appear
in this list, and
that are both currently connected and streaming data in real-time
(as shown by a state of streaming in the
pg_stat_replication view).
Specifying more than one synchronous standby can allow for very high
availability and protection against data loss.
The name of a standby server for this purpose is the
application_name setting of the standby, as set in the
standby's connection information. In case of a physical replication
standby, this should be set in the primary_conninfo
setting; the default is the setting of cluster_name
if set, else walreceiver.
For logical replication, this can be set in the connection
information of the subscription, and it defaults to the
subscription name. For other replication stream consumers,
consult their documentation.
This parameter specifies a list of standby servers using either of the following syntaxes:
[FIRST]num_sync(standby_name[, ...] ) ANYnum_sync(standby_name[, ...] )standby_name[, ...]
where num_sync is
the number of synchronous standbys that transactions need to
wait for replies from,
and standby_name
is the name of a standby server.
num_sync
must be an integer value greater than zero.
FIRST and ANY specify the method to choose
synchronous standbys from the listed servers.
The keyword FIRST, coupled with
num_sync, specifies a
priority-based synchronous replication and makes transaction commits
wait until their WAL records are replicated to
num_sync synchronous
standbys chosen based on their priorities. For example, a setting of
FIRST 3 (s1, s2, s3, s4) will cause each commit to wait for
replies from three higher-priority standbys chosen from standby servers
s1, s2, s3 and s4.
The standbys whose names appear earlier in the list are given higher
priority and will be considered as synchronous. Other standby servers
appearing later in this list represent potential synchronous standbys.
If any of the current synchronous standbys disconnects for whatever
reason, it will be replaced immediately with the next-highest-priority
standby. The keyword FIRST is optional.
The keyword ANY, coupled with
num_sync, specifies a
quorum-based synchronous replication and makes transaction commits
wait until their WAL records are replicated to at least
num_sync listed standbys.
For example, a setting of ANY 3 (s1, s2, s3, s4) will cause
each commit to proceed as soon as at least any three standbys of
s1, s2, s3 and s4
reply.
FIRST and ANY are case-insensitive. If these
keywords are used as the name of a standby server,
its standby_name must
be double-quoted.
The third syntax was used before PostgreSQL
version 9.6 and is still supported. It's the same as the first syntax
with FIRST and
num_sync equal to 1.
For example, FIRST 1 (s1, s2) and s1, s2 have
the same meaning: either s1 or s2 is chosen
as a synchronous standby.
The special entry * matches any standby name.
There is no mechanism to enforce uniqueness of standby names. In case of duplicates one of the matching standbys will be considered as higher priority, though exactly which one is indeterminate.
Note
Each standby_name
should have the form of a valid SQL identifier, unless it
is *. You can use double-quoting if necessary. But note
that standby_names are
compared to standby application names case-insensitively, whether
double-quoted or not.
If no synchronous standby names are specified here, then synchronous
replication is not enabled and transaction commits will not wait for
replication. This is the default configuration. Even when
synchronous replication is enabled, individual transactions can be
configured not to wait for replication by setting the
synchronous_commit parameter to
local or off.
This parameter can only be set in the postgresql.conf
file or on the server command line.
Compare versions
Complete source facts
doc html
<p>
Specifies a list of standby servers that can support
<em class="firstterm">synchronous replication</em>, as described in
<a class="xref" href="/docs/18/warm-standby.html#SYNCHRONOUS-REPLICATION" title="26.2.8. Synchronous Replication">Section 26.2.8</a>.
There will be one or more active synchronous standbys;
transactions waiting for commit will be allowed to proceed after
these standby servers confirm receipt of their data.
The synchronous standbys will be those whose names appear
in this list, and
that are both currently connected and streaming data in real-time
(as shown by a state of <code class="literal">streaming</code> in the
<a class="link" href="/docs/18/monitoring-stats.html#MONITORING-PG-STAT-REPLICATION-VIEW" title="27.2.4. pg_stat_replication">
<code class="structname">pg_stat_replication</code></a> view).
Specifying more than one synchronous standby can allow for very high
availability and protection against data loss.
</p><p>
The name of a standby server for this purpose is the
<code class="varname">application_name</code> setting of the standby, as set in the
standby's connection information. In case of a physical replication
standby, this should be set in the <code class="varname">primary_conninfo</code>
setting; the default is the setting of <a class="xref" href="/docs/18/runtime-config-logging.html#GUC-CLUSTER-NAME">cluster_name</a>
if set, else <code class="literal">walreceiver</code>.
For logical replication, this can be set in the connection
information of the subscription, and it defaults to the
subscription name. For other replication stream consumers,
consult their documentation.
</p><p>
This parameter specifies a list of standby servers using
either of the following syntaxes:
</p><pre class="synopsis">
[FIRST] <em class="replaceable"><code>num_sync</code></em> ( <em class="replaceable"><code>standby_name</code></em> [, ...] )
ANY <em class="replaceable"><code>num_sync</code></em> ( <em class="replaceable"><code>standby_name</code></em> [, ...] )
<em class="replaceable"><code>standby_name</code></em> [, ...]
</pre><p>
where <em class="replaceable"><code>num_sync</code></em> is
the number of synchronous standbys that transactions need to
wait for replies from,
and <em class="replaceable"><code>standby_name</code></em>
is the name of a standby server.
<em class="replaceable"><code>num_sync</code></em>
must be an integer value greater than zero.
<code class="literal">FIRST</code> and <code class="literal">ANY</code> specify the method to choose
synchronous standbys from the listed servers.
</p><p>
The keyword <code class="literal">FIRST</code>, coupled with
<em class="replaceable"><code>num_sync</code></em>, specifies a
priority-based synchronous replication and makes transaction commits
wait until their WAL records are replicated to
<em class="replaceable"><code>num_sync</code></em> synchronous
standbys chosen based on their priorities. For example, a setting of
<code class="literal">FIRST 3 (s1, s2, s3, s4)</code> will cause each commit to wait for
replies from three higher-priority standbys chosen from standby servers
<code class="literal">s1</code>, <code class="literal">s2</code>, <code class="literal">s3</code> and <code class="literal">s4</code>.
The standbys whose names appear earlier in the list are given higher
priority and will be considered as synchronous. Other standby servers
appearing later in this list represent potential synchronous standbys.
If any of the current synchronous standbys disconnects for whatever
reason, it will be replaced immediately with the next-highest-priority
standby. The keyword <code class="literal">FIRST</code> is optional.
</p><p>
The keyword <code class="literal">ANY</code>, coupled with
<em class="replaceable"><code>num_sync</code></em>, specifies a
quorum-based synchronous replication and makes transaction commits
wait until their WAL records are replicated to <span class="emphasis"><em>at least</em></span>
<em class="replaceable"><code>num_sync</code></em> listed standbys.
For example, a setting of <code class="literal">ANY 3 (s1, s2, s3, s4)</code> will cause
each commit to proceed as soon as at least any three standbys of
<code class="literal">s1</code>, <code class="literal">s2</code>, <code class="literal">s3</code> and <code class="literal">s4</code>
reply.
</p><p>
<code class="literal">FIRST</code> and <code class="literal">ANY</code> are case-insensitive. If these
keywords are used as the name of a standby server,
its <em class="replaceable"><code>standby_name</code></em> must
be double-quoted.
</p><p>
The third syntax was used before <span class="productname">PostgreSQL</span>
version 9.6 and is still supported. It's the same as the first syntax
with <code class="literal">FIRST</code> and
<em class="replaceable"><code>num_sync</code></em> equal to 1.
For example, <code class="literal">FIRST 1 (s1, s2)</code> and <code class="literal">s1, s2</code> have
the same meaning: either <code class="literal">s1</code> or <code class="literal">s2</code> is chosen
as a synchronous standby.
</p><p>
The special entry <code class="literal">*</code> matches any standby name.
</p><p>
There is no mechanism to enforce uniqueness of standby names. In case
of duplicates one of the matching standbys will be considered as
higher priority, though exactly which one is indeterminate.
</p><div class="note"><h3 class="title">Note</h3><p>
Each <em class="replaceable"><code>standby_name</code></em>
should have the form of a valid SQL identifier, unless it
is <code class="literal">*</code>. You can use double-quoting if necessary. But note
that <em class="replaceable"><code>standby_name</code></em>s are
compared to standby application names case-insensitively, whether
double-quoted or not.
</p></div><p>
If no synchronous standby names are specified here, then synchronous
replication is not enabled and transaction commits will not wait for
replication. This is the default configuration. Even when
synchronous replication is enabled, individual transactions can be
configured not to wait for replication by setting the
<a class="xref" href="/docs/18/runtime-config-wal.html#GUC-SYNCHRONOUS-COMMIT">synchronous_commit</a> parameter to
<code class="literal">local</code> or <code class="literal">off</code>.
</p><p>
This parameter can only be set in the <code class="filename">postgresql.conf</code>
file or on the server command line.
</p>documentation revision
{"inputs":[{"file":"runtime-config-replication.html","kind":"same-version-reviewed-manual","locale":"en","sha256":"c0b8bd86131ec62d4df97ce480d004aa7e3544477d053f0c2d4047b9edad5cc0","version":"18.7"},{"file":"runtime-config-replication.html","kind":"same-version-reviewed-manual","locale":"zh-Hans","sha256":"83907b5f469e979a7b9ec875b5e7bdaa2ef6b85596ca31b45174f68cd7398b18","version":"18.7"}],"release":"18.7","runtime_remeasured":false,"source_revision":"pgdoc:b9f0e7232f60f380d642ac9b99226606c254b552"}Source references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · wiki-repair-20261023:62422e3fda88bb3ada48f81ba456a1b09ed29231d6316f681396361053706278
Text language: en · wiki-repair-20261023:62422e3fda88bb3ada48f81ba456a1b09ed29231d6316f681396361053706278