<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="group-replication-restarting-group">
      </a>
      20.5.2 Restarting a Group
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045133439136">
  </a>
  <p>
   Group Replication is designed to ensure that the database service
      is continuously available, even if some of the servers that form
      the group are currently unable to participate in it due to planned
      maintenance or unplanned issues. As long as the remaining members
      are a majority of the group they can elect a new primary and
      continue to function as a group. However, if every member of a
      replication group leaves the group, and Group Replication is
      stopped on every member by a
   <a class="link" href="stop-group-replication.html" title="15.4.3.2 STOP GROUP_REPLICATION Statement">
    <code class="literal">
     STOP
      GROUP_REPLICATION
    </code>
   </a>
   statement or system shutdown, the
      group now only exists in theory, as a configuration on the
      members. In that situation, to re-create the group, it must be
      started by bootstrapping as if it was being started for the first
      time.
  </p>
  <p>
   The difference between bootstrapping a group for the first time
      and doing it for the second or subsequent times is that in the
      latter situation, the members of a group that was shut down might
      have different transaction sets from each other, depending on the
      order in which they were stopped or failed. A member cannot join a
      group if it has transactions that are not present on the other
      group members. For Group Replication, this includes both
      transactions that have been committed and applied, which are in
      the
   <a class="link" href="replication-options-gtids.html#sysvar_gtid_executed">
    <code class="literal">
     gtid_executed
    </code>
   </a>
   GTID set, and
      transactions that have been certified but not yet applied, which
      are in the
   <code class="literal">
    group_replication_applier
   </code>
   channel.
      The exact point at which a transaction is committed depends on the
      transaction consistency level that is set for the group (see
   <a class="xref" href="group-replication-consistency-guarantees.html" title="20.5.3 Transaction Consistency Guarantees">
    Section 20.5.3, “Transaction Consistency Guarantees”
   </a>
   ).
      However, a Group Replication group member never removes a
      transaction that has been certified, which is a declaration of the
      member’s intent to commit the transaction.
  </p>
  <p>
   The replication group must therefore be restarted beginning with
      the most up to date member, that is, the member that has the most
      transactions executed and certified. The members with fewer
      transactions can then join and catch up with the transactions they
      are missing through distributed recovery. It is not correct to
      assume that the last known primary member of the group is the most
      up to date member of the group, because a member that was shut
      down later than the primary might have more transactions. You must
      therefore restart each member to check the transactions, compare
      all the transaction sets, and identify the most up to date member.
      This member can then be used to bootstrap the group.
  </p>
  <p>
   Follow this procedure to restart a replication group safely after
      every member shuts down.
  </p>
  <div class="orderedlist">
   <ol class="orderedlist" type="1">
    <li class="listitem">
     <p>
      For each group member in turn, in any order:
     </p>
     <div class="orderedlist">
      <ol class="orderedlist" type="a">
       <li class="listitem">
        <p>
         Connect a client to the group member. If Group Replication
              is not already stopped, issue a
         <a class="link" href="stop-group-replication.html" title="15.4.3.2 STOP GROUP_REPLICATION Statement">
          <code class="literal">
           STOP
              GROUP_REPLICATION
          </code>
         </a>
         statement and wait for Group
              Replication to stop.
        </p>
       </li>
       <li class="listitem">
        <p>
         Edit the MySQL Server configuration file (typically named
         <code class="filename">
          my.cnf
         </code>
         on Linux and Unix systems, or
         <code class="filename">
          my.ini
         </code>
         on Windows systems) and set
              the system variable
         <a class="link" href="group-replication-system-variables.html#sysvar_group_replication_start_on_boot">
          <code class="literal">
           group_replication_start_on_boot=OFF
          </code>
         </a>
         .
              This setting prevents Group Replication from starting when
              MySQL Server is started, which is the default.
        </p>
        <p>
         If you cannot change that setting on the system, you can
              just allow the server to attempt to start Group
              Replication, which will fail because the group has been
              fully shut down and not yet bootstrapped. If you take that
              approach, do not set
         <a class="link" href="group-replication-system-variables.html#sysvar_group_replication_bootstrap_group">
          <code class="literal">
           group_replication_bootstrap_group=ON
          </code>
         </a>
         on any server at this stage.
        </p>
       </li>
       <li class="listitem">
        <p>
         Start the MySQL Server instance, and verify that Group
              Replication has not been started (or has failed to start).
              Do not start Group Replication at this stage.
        </p>
       </li>
       <li class="listitem">
        <p>
         Collect the following information from the group member:
        </p>
        <div class="itemizedlist">
         <ul class="itemizedlist" style="list-style-type: disc; ">
          <li class="listitem">
           <p>
            The contents of the
            <a class="link" href="replication-options-gtids.html#sysvar_gtid_executed">
             <code class="literal">
              gtid_executed
             </code>
            </a>
            GTID
                  set. You can get this by issuing the following
                  statement:
           </p>
           <div class="copytoclipboard-wrapper">
            <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa55063351"><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> <span class="token variable">@@GLOBAL.GTID_EXECUTED</span></code></pre>
           </div>
          </li>
          <li class="listitem">
           <p>
            The set of certified transactions on the
            <code class="literal">
             group_replication_applier
            </code>
            channel.
                  You can get this by issuing the following statement:
           </p>
           <div class="copytoclipboard-wrapper">
            <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa45808774"><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> received_transaction_set <span class="token keyword">FROM</span> \
        performance_schema<span class="token punctuation">.</span>replication_connection_status <span class="token keyword">WHERE</span> \
        channel_name<span class="token operator">=</span><span class="token string">"group_replication_applier"</span><span class="token punctuation">;</span></code></pre>
           </div>
          </li>
         </ul>
        </div>
       </li>
      </ol>
     </div>
    </li>
    <li class="listitem">
     <p>
      When you have collected the transaction sets from all the
          group members, compare them to find which member has the
          biggest transaction set overall, including both the executed
          transactions (
      <a class="link" href="replication-options-gtids.html#sysvar_gtid_executed">
       <code class="literal">
        gtid_executed
       </code>
      </a>
      )
          and the certified transactions (on the
      <code class="literal">
       group_replication_applier
      </code>
      channel). You can
          do this manually by looking at the GTIDs, or you can compare
          the GTID sets using stored functions, as described in
      <a class="xref" href="replication-gtids-functions.html" title="19.1.3.8 Stored Function Examples to Manipulate GTIDs">
       Section 19.1.3.8, “Stored Function Examples to Manipulate GTIDs”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      Use the member that has the biggest transaction set to
          bootstrap the group, by connecting a client to the group
          member and issuing the following statements:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa88989486"><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">SET</span> <span class="token keyword">GLOBAL</span> group_replication_bootstrap_group<span class="token operator">=</span><span class="token keyword">ON</span><span class="token punctuation">;</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">START</span> <span class="token keyword">GROUP_REPLICATION</span><span class="token punctuation">;</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> group_replication_bootstrap_group<span class="token operator">=</span><span class="token keyword">OFF</span><span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      It is important not to store the setting
      <a class="link" href="group-replication-system-variables.html#sysvar_group_replication_bootstrap_group">
       <code class="literal">
        group_replication_bootstrap_group=ON
       </code>
      </a>
      in the configuration file, otherwise when the server is
          restarted again, a second group with the same name is set up.
     </p>
    </li>
    <li class="listitem">
     <p>
      To verify that the group now exists with this founder member
          in it, issue this statement on the member that bootstrapped
          it:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa40705729"><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> <span class="token operator">*</span> <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>replication_group_members<span class="token punctuation">;</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Add each of the other members back into the group, in any
          order, by issuing a
      <a class="link" href="start-group-replication.html" title="15.4.3.1 START GROUP_REPLICATION Statement">
       <code class="literal">
        START
          GROUP_REPLICATION
       </code>
      </a>
      statement on each of them:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa35040007"><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">START</span> <span class="token keyword">GROUP_REPLICATION</span><span class="token punctuation">;</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      To verify that each member has joined the group, issue this
          statement on any member:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa10213592"><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> <span class="token operator">*</span> <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>replication_group_members<span class="token punctuation">;</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      When the members have rejoined the group, if you edited their
          configuration files to set
      <a class="link" href="group-replication-system-variables.html#sysvar_group_replication_start_on_boot">
       <code class="literal">
        group_replication_start_on_boot=OFF
       </code>
      </a>
      ,
          you can edit them again to set
      <code class="literal">
       ON
      </code>
      (or
          remove the system variable, since
      <code class="literal">
       ON
      </code>
      is the
          default).
     </p>
    </li>
   </ol>
  </div>
 </div>
 <br/>
</div>
