Home Explore Blog CI



postgresql

73th chunk of `doc/src/sgml/config.sgml`
3ae332c264968d0ee84f8b99c0137863fd7f5ef75e320f640000000100000fa2
 <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 with the next-highest-priority
        standby. The keyword <literal>FIRST</literal> is optional.
       </para>
       <para>
        The keyword <literal>ANY</literal>, coupled with
        <replaceable class="parameter">num_sync</replaceable>, specifies a
        quorum-based synchronous replication and makes transaction commits
        wait until their WAL records are replicated to <emphasis>at least</emphasis>
        <replaceable class="parameter">num_sync</replaceable> listed standbys.
        For example, a setting of <literal>ANY 3 (s1, s2, s3, s4)</literal> will cause
        each commit to proceed as soon as at least any three standbys of
        <literal>s1</literal>, <literal>s2</literal>, <literal>s3</literal> and <literal>s4</literal>
        reply.
       </para>
       <para>
        <literal>FIRST</literal> and <literal>ANY</literal> are case-insensitive. If these
        keywords are used as the name of a standby server,
        its <replaceable class="parameter">standby_name</replaceable> must
        be double-quoted.
       </para>
       <para>
        The third syntax was used before <productname>PostgreSQL</productname>
        version 9.6 and is still supported. It's the same as the first syntax
        with <literal>FIRST</literal> and
        <replaceable class="parameter">num_sync</replaceable> equal to 1.
        For example, <literal>FIRST 1 (s1, s2)</literal> and <literal>s1, s2</literal> have
        the same meaning: either <literal>s1</literal> or <literal>s2</literal> is chosen
        as a synchronous standby.
       </para>
       <para>
        The special entry <literal>*</literal> matches any standby name.
       </para>
       <para>
        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.
       </para>
       <note>
        <para>
         Each <replaceable class="parameter">standby_name</replaceable>
         should have the form of a valid SQL identifier, unless it
         is <literal>*</literal>.  You can use double-quoting if necessary.  But note
         that <replaceable class="parameter">standby_name</replaceable>s are
         compared to standby application names case-insensitively, whether
         double-quoted or not.
        </para>
       </note>
       <para>
        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
        <xref linkend="guc-synchronous-commit"/> parameter to
        <literal>local</literal> or <literal>off</literal>.
       </para>
       <para>
        This parameter can only be set in the

Title: Advanced Configuration Options for Synchronous Standby Names
Summary
This section further elaborates on the `synchronous_standby_names` parameter, detailing the functionality of the `FIRST` and `ANY` keywords for priority-based and quorum-based synchronous replication, respectively. It clarifies how these keywords determine which standbys are considered synchronous and how failover is handled. It also explains the backward compatibility with the pre-9.6 syntax and the use of '*' to match any standby name. Additionally, it discusses the case-insensitive comparison of standby names and the implications of not enabling synchronous standbys.