id="guc-synchronous-standby-names" xreflabel="synchronous_standby_names">
<term><varname>synchronous_standby_names</varname> (<type>string</type>)
<indexterm>
<primary><varname>synchronous_standby_names</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<para>
Specifies a list of standby servers that can support
<firstterm>synchronous replication</firstterm>, as described in
<xref linkend="synchronous-replication"/>.
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 <literal>streaming</literal> in the
<link linkend="monitoring-pg-stat-replication-view">
<structname>pg_stat_replication</structname></link> view).
Specifying more than one synchronous standby can allow for very high
availability and protection against data loss.
</para>
<para>
The name of a standby server for this purpose is the
<varname>application_name</varname> 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 <varname>primary_conninfo</varname>
setting; the default is the setting of <xref linkend="guc-cluster-name"/>
if set, else <literal>walreceiver</literal>.
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.
</para>
<para>
This parameter specifies a list of standby servers using
either of the following syntaxes:
<synopsis>
[FIRST] <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="parameter">standby_name</replaceable> [, ...] )
ANY <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="parameter">standby_name</replaceable> [, ...] )
<replaceable class="parameter">standby_name</replaceable> [, ...]
</synopsis>
where <replaceable class="parameter">num_sync</replaceable> is
the number of synchronous standbys that transactions need to
wait for replies from,
and <replaceable class="parameter">standby_name</replaceable>
is the name of a standby server.
<replaceable class="parameter">num_sync</replaceable>
must be an integer value greater than zero.
<literal>FIRST</literal> and <literal>ANY</literal> specify the method to choose
synchronous standbys from the listed servers.
</para>
<para>
The keyword <literal>FIRST</literal>, coupled with
<replaceable class="parameter">num_sync</replaceable>, specifies a
priority-based synchronous replication and makes transaction commits
wait until their WAL records are replicated to
<replaceable class="parameter">num_sync</replaceable> synchronous
standbys chosen based on their priorities. For example, a setting of
<literal>FIRST 3 (s1, s2, s3, s4)</literal> will cause each commit to wait for
replies from three higher-priority standbys chosen from standby servers
<literal>s1</literal>, <literal>s2</literal>, <literal>s3</literal> and <literal>s4</literal>.
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