<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="group-replication-functions-for-member-actions">
      </a>
      14.18.1.5 Functions to Set and Reset Group Replication Member Actions
     </h4>
    </div>
   </div>
  </div>
  <p>
   The following functions can be used to enable and disable
          actions for members of a group to take in specified
          situations, and to reset the configuration to the default
          setting for all member actions. They can only be used by
          administrators with the
   <a class="link" href="privileges-provided.html#priv_group-replication-admin">
    <code class="literal">
     GROUP_REPLICATION_ADMIN
    </code>
   </a>
   privilege or the deprecated
   <a class="link" href="privileges-provided.html#priv_super">
    <code class="literal">
     SUPER
    </code>
   </a>
   privilege.
  </p>
  <p>
   You configure member actions on the group’s primary using
          the
   <a class="link" href="group-replication-functions-for-member-actions.html#function_group-replication-enable-member-action">
    <code class="literal">
     group_replication_enable_member_action
    </code>
   </a>
   and
   <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>
   functions. The member actions configuration, consisting of all
          the member actions and whether they are enabled or disabled,
          is then propagated to other group members and joining members
          using Group Replication’s group messages. This means that
          the group members will all act in the same way when they are
          in the specified situation, and you only need to use the
          function on the primary.
  </p>
  <p>
   The functions can also be used on a server that is not part of
          a group, as long as the Group Replication plugin is installed.
          In that case, the member actions configuration is not
          propagated to any other servers.
  </p>
  <p>
   The
   <a class="link" href="group-replication-functions-for-member-actions.html#function_group-replication-reset-member-actions">
    <code class="literal">
     group_replication_reset_member_actions
    </code>
   </a>
   function can only be used on a server that is not part of a
          group. It resets the member actions configuration to the
          default settings, and resets its version number. The server
          must be writeable (with the
   <a class="link" href="server-system-variables.html#sysvar_read_only">
    <code class="literal">
     read_only
    </code>
   </a>
   system variable set
          to
   <code class="literal">
    OFF
   </code>
   ) and have the Group Replication
          plugin installed.
  </p>
  <p>
   The available member actions are as follows:
  </p>
  <div class="variablelist">
   <dl class="variablelist">
    <dt>
     <span class="term">
      <code class="literal">
       mysql_disable_super_read_only_if_primary
      </code>
     </span>
    </dt>
    <dd>
     <p>
      This member action is taken after a member is elected as
                the group’s primary, which is the event
      <code class="literal">
       AFTER_PRIMARY_ELECTION
      </code>
      . The member
                action is enabled by default. You can disable it 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, and re-enable it using
      <a class="link" href="group-replication-functions-for-member-actions.html#function_group-replication-enable-member-action">
       <code class="literal">
        group_replication_enable_member_action()
       </code>
      </a>
      .
     </p>
     <p>
      When this member action is enabled and taken, super
                read-only mode is disabled on the primary, so that the
                primary becomes read-write and accepts updates from a
                replication source server and from clients. This is the
                normal situation.
     </p>
     <p>
      When this member action is disabled and not taken, the
                primary remains in super read-only mode after election.
                In this state, it does not accept updates from any
                clients, even users who have the
      <a class="link" href="privileges-provided.html#priv_connection-admin">
       <code class="literal">
        CONNECTION_ADMIN
       </code>
      </a>
      or
      <a class="link" href="privileges-provided.html#priv_super">
       <code class="literal">
        SUPER
       </code>
      </a>
      privilege. It does
                continue to accept updates performed by replication
                threads. This setup means that when a group’s purpose
                is to provide a secondary backup to another group for
                disaster tolerance, you can ensure that the secondary
                group remains synchronized with the first.
     </p>
    </dd>
    <dt>
     <span class="term">
      <code class="literal">
       mysql_start_failover_channels_if_primary
      </code>
     </span>
    </dt>
    <dd>
     <p>
      This member action is taken after a member is elected as
                the group’s primary, which is the event
      <code class="literal">
       AFTER_PRIMARY_ELECTION
      </code>
      . The member
                action is enabled by default. You can disable it 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, and re-enable it using the
      <a class="link" href="group-replication-functions-for-member-actions.html#function_group-replication-enable-member-action">
       <code class="literal">
        group_replication_enable_member_action()
       </code>
      </a>
      function.
     </p>
     <p>
      When this member action is enabled, asynchronous
                connection failover for replicas is active for a
                replication channel on a Group Replication primary when
                you set
      <code class="literal">
       SOURCE_CONNECTION_AUTO_FAILOVER=1
      </code>
      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. 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. This is the normal situation. For
                instructions to configure the feature, see
      <a class="xref" href="replication-asynchronous-connection-failover-replica.html" title="19.4.9.2 Asynchronous Connection Failover for Replicas">
       Section 19.4.9.2, “Asynchronous Connection Failover for Replicas”
      </a>
      .
     </p>
     <p>
      When this member action is disabled, asynchronous
                connection failover does not take place for the
                replicas. 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 this
                method. Set
      <code class="literal">
       SOURCE_CONNECTION_AUTO_FAILOVER=0
      </code>
      to
                disable an individual channel.
     </p>
    </dd>
   </dl>
  </div>
  <p>
   For more information on member actions and how to view the
          member actions configuration, see
   <a class="xref" href="group-replication-member-actions.html" title="20.5.1.5 Configuring Member Actions">
    Section 20.5.1.5, “Configuring Member Actions”
   </a>
   .
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a name="function_group-replication-disable-member-action">
      </a>
      <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>
     </p>
     <a class="indexterm" name="idm46045193733984">
     </a>
     <a class="indexterm" name="idm46045193732880">
     </a>
     <p>
      Disable a member action so that the member does not take
              it in the specified situation. If the server where you use
              the function is part of a group, it must be the current
              primary in a group in single-primary mode, and it must be
              part of the majority. The changed setting is propagated to
              other group members and joining members, so they will all
              act in the same way when they are in the specified
              situation, and you only need to use the function on the
              primary.
     </p>
     <p>
      Syntax:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-clike"><div class="docs-select-all right" id="sa91963102"><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-clike">STRING <span class="token function">group_replication_disable_member_action</span><span class="token punctuation">(</span><em class="replaceable">name</em><span class="token punctuation">,</span> <em class="replaceable">event</em><span class="token punctuation">)</span></code></pre>
     </div>
     <p>
      Arguments:
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         <em class="replaceable">
          <code>
           name
          </code>
         </em>
         : The name of the
                  member action to disable.
        </p>
       </li>
       <li class="listitem">
        <p>
         <em class="replaceable">
          <code>
           event
          </code>
         </em>
         : The event that
                  triggers the member action.
        </p>
       </li>
      </ul>
     </div>
     <p>
      Return value:
     </p>
     <p>
      A string containing the result of the operation, for
              example whether it was successful or not.
     </p>
     <p>
      Example:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa84434621"><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 keyword">SELECT</span> group_replication_disable_member_action<span class="token punctuation">(</span><span class="token string">"mysql_disable_super_read_only_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>
      For more information, see
      <a class="xref" href="group-replication-member-actions.html" title="20.5.1.5 Configuring Member Actions">
       Section 20.5.1.5, “Configuring Member Actions”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <a name="function_group-replication-enable-member-action">
      </a>
      <a class="link" href="group-replication-functions-for-member-actions.html#function_group-replication-enable-member-action">
       <code class="literal">
        group_replication_enable_member_action()
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045193718016">
     </a>
     <a class="indexterm" name="idm46045193716912">
     </a>
     <p>
      Enable a member action for the member to take in the
              specified situation. If the server where you use the
              function is part of a group, it must be the current
              primary in a group in single-primary mode, and it must be
              part of the majority. The changed setting is propagated to
              other group members and joining members, so they will all
              act in the same way when they are in the specified
              situation, and you only need to use the function on the
              primary.
     </p>
     <p>
      Syntax:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-clike"><div class="docs-select-all right" id="sa47034852"><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-clike">STRING <span class="token function">group_replication_enable_member_action</span><span class="token punctuation">(</span><em class="replaceable">name</em><span class="token punctuation">,</span> <em class="replaceable">event</em><span class="token punctuation">)</span></code></pre>
     </div>
     <p>
      Arguments:
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         <em class="replaceable">
          <code>
           name
          </code>
         </em>
         : The name of the
                  member action to enable.
        </p>
       </li>
       <li class="listitem">
        <p>
         <em class="replaceable">
          <code>
           event
          </code>
         </em>
         : The event that
                  triggers the member action.
        </p>
       </li>
      </ul>
     </div>
     <p>
      Return value:
     </p>
     <p>
      A string containing the result of the operation, for
              example whether it was successful or not.
     </p>
     <p>
      Example:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa42542503"><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 keyword">SELECT</span> group_replication_enable_member_action<span class="token punctuation">(</span><span class="token string">"mysql_disable_super_read_only_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>
      For more information, see
      <a class="xref" href="group-replication-member-actions.html" title="20.5.1.5 Configuring Member Actions">
       Section 20.5.1.5, “Configuring Member Actions”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <a name="function_group-replication-reset-member-actions">
      </a>
      <a class="link" href="group-replication-functions-for-member-actions.html#function_group-replication-reset-member-actions">
       <code class="literal">
        group_replication_reset_member_actions()
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045193702128">
     </a>
     <a class="indexterm" name="idm46045193701024">
     </a>
     <p>
      Reset the member actions configuration to the default
              settings, and reset its version number to 1.
     </p>
     <p>
      The
      <a class="link" href="group-replication-functions-for-member-actions.html#function_group-replication-reset-member-actions">
       <code class="literal">
        group_replication_reset_member_actions()
       </code>
      </a>
      function can only be used on a server that is not
              currently part of a group. The server must be writeable
              (with the
      <a class="link" href="server-system-variables.html#sysvar_read_only">
       <code class="literal">
        read_only
       </code>
      </a>
      system variable set to
      <code class="literal">
       OFF
      </code>
      ) and have
              the Group Replication plugin installed. You can use this
              function to remove the member actions configuration that a
              server used when it was part of a group, if you intend to
              use it as a standalone server with no member actions or
              different member actions.
     </p>
     <p>
      Syntax:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-clike"><div class="docs-select-all right" id="sa31330780"><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-clike">STRING <span class="token function">group_replication_reset_member_actions</span><span class="token punctuation">(</span><span class="token punctuation">)</span></code></pre>
     </div>
     <p>
      Arguments:
     </p>
     <p>
      None.
     </p>
     <p>
      Return value:
     </p>
     <p>
      A string containing the result of the operation, for
              example whether it was successful or not.
     </p>
     <p>
      Example:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa89790283"><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 keyword">SELECT</span> group_replication_reset_member_actions<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      For more information, see
      <a class="xref" href="group-replication-member-actions.html" title="20.5.1.5 Configuring Member Actions">
       Section 20.5.1.5, “Configuring Member Actions”
      </a>
      .
     </p>
    </li>
   </ul>
  </div>
 </div>
 <br/>
</div>
