<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="replication-asynchronous-connection-failover-replica">
      </a>
      19.4.9.2 Asynchronous Connection Failover for Replicas
     </h4>
    </div>
   </div>
  </div>
  <p>
   Asynchronous connection failover for replicas is activated
        automatically for a replication channel on a Group Replication
        primary when you set
   <a class="link" href="change-replication-source-to.html#crs-opt-source_connection_auto_failover">
    <code class="literal">
     SOURCE_CONNECTION_AUTO_FAILOVER=1
    </code>
   </a>
   in the
   <a class="link" href="change-replication-source-to.html" title="15.4.2.2 CHANGE REPLICATION SOURCE TO Statement">
    <code class="literal">
     CHANGE REPLICATION SOURCE
        TO
    </code>
   </a>
   statement for the channel. The feature is designed
        for a group of senders and a group of receivers to keep
        synchronized with each other even when some members are
        temporarily unavailable. When the feature is active and
        correctly configured, if the primary that is replicating goes
        offline or into an error state, the new primary starts
        replication on the same channel when it is elected. The new
        primary uses the source list for the channel to select the
        source with the highest priority (weight) setting, which might
        not be the same as the original source.
  </p>
  <p>
   To configure this feature, the replication channel and the
        replication user account and password for the channel must be
        set up on all the member servers in the replication group, and
        on any new joining members. Ensure that
   <a class="link" href="change-replication-source-to.html#crs-opt-source_retry_count">
    <code class="literal">
     SOURCE_RETRY_COUNT
    </code>
   </a>
   and
   <a class="link" href="change-replication-source-to.html#crs-opt-source_connect_retry">
    <code class="literal">
     SOURCE_CONNECT_RETRY
    </code>
   </a>
   are set to
        minimal numbers that just allow a few retry attempts, for
        example 3 and 10. You can set up the replication channel using
   <code class="literal">
    CHANGE REPLICATION SOURCE TO
   </code>
   , or if the new
        servers are provisioned using MySQL's clone functionality,
        this all happens automatically. The
   <code class="literal">
    SOURCE_CONNECTION_AUTO_FAILOVER
   </code>
   setting for
        the channel is broadcast to group members from the primary when
        they join. If you later disable
   <code class="literal">
    SOURCE_CONNECTION_AUTO_FAILOVER
   </code>
   for the
        channel on the primary, this is also broadcast to the secondary
        servers, and they change the status of the channel to match.
  </p>
  <p>
   Asynchronous connection failover for replicas is activated and
        deactivated using the Group Replication member action
   <code class="literal">
    mysql_start_failover_channels_if_primary
   </code>
   ,
        which is enabled by default. You can disable it for the whole
        group by disabling that member action on the primary, using the
   <a class="link" href="group-replication-functions-for-member-actions.html#function_group-replication-disable-member-action">
    <code class="literal">
     group_replication_disable_member_action
    </code>
   </a>
   function, as in this example:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa42307891"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> group_replication_disable_member_action<span class="token punctuation">(</span><span class="token string">"mysql_start_failover_channels_if_primary"</span><span class="token punctuation">,</span> <span class="token string">"AFTER_PRIMARY_ELECTION"</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   The function can only be changed on a primary, and must be
        enabled or disabled for the whole group, so you cannot have some
        members providing failover and others not. When the
   <code class="literal">
    mysql_start_failover_channels_if_primary
   </code>
   member action is disabled, the channel does not need to be
        configured on secondary members, but if the primary goes offline
        or into an error state, replication stops for the channel. Note
        that if there is more than one channel with
   <code class="literal">
    SOURCE_CONNECTION_AUTO_FAILOVER=1
   </code>
   , the
        member action covers all the channels, so they cannot be
        individually enabled and disabled by that method. Set
   <code class="literal">
    SOURCE_CONNECTION_AUTO_FAILOVER=0
   </code>
   on the
        primary to disable an individual channel.
  </p>
  <p>
   The source list for a channel with
   <code class="literal">
    SOURCE_CONNECTION_AUTO_FAILOVER=1
   </code>
   is
        broadcast to all group members when they join, and also when it
        changes. This is the case whether the sources are a managed
        group for which the membership is updated automatically, or
        whether they are added or changed manually using
   <a class="link" href="replication-functions-async-failover.html#function_asynchronous-connection-failover-add-source">
    <code class="literal">
     asynchronous_connection_failover_add_source()
    </code>
   </a>
   ,
   <a class="link" href="replication-functions-async-failover.html#function_asynchronous-connection-failover-delete-source">
    <code class="literal">
     asynchronous_connection_failover_delete_source()
    </code>
   </a>
   ,
   <a class="link" href="replication-functions-async-failover.html#function_asynchronous-connection-failover-add-managed">
    <code class="literal">
     asynchronous_connection_failover_add_managed()
    </code>
   </a>
   ,
        or
   <a class="link" href="replication-functions-async-failover.html#function_asynchronous-connection-failover-delete-managed">
    <code class="literal">
     asynchronous_connection_failover_delete_managed()
    </code>
   </a>
   .
        All group members receive the current source list as recorded in
        the
   <code class="literal">
    mysql.replication_asynchronous_connection_failover
   </code>
   and
   <code class="literal">
    mysql.replication_asynchronous_connection_failover_managed
   </code>
   tables. Because the sources do not have to be in a managed
        group, you can set up the function to synchronize a group of
        receivers with one or more alternative standalone senders, or
        even a single sender. A standalone replica that is not part of a
        replication group cannot use this feature.
  </p>
 </div>
 <br/>
</div>
