<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="replication-mode-change-online-concepts">
      </a>
      19.1.4.1 Replication Mode Concepts
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045145596608">
  </a>
  <p>
   Before setting the replication mode of an online server, it is
      important to understand some key concepts of replication. This
      section explains these concepts and is essential reading before
      attempting to modify the replication mode of an online server.
  </p>
  <p>
   The modes of replication available in MySQL rely on different
      techniques for identifying logged transactions. The types of
      transactions used by replication are listed here:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      A GTID transaction is identified by a global transaction
          identifier (GTID) which takes one of two forms:
      <code class="literal">
       UUID:NUMBER
      </code>
      or
      <code class="literal">
       UUID:TAG:NUMBER
      </code>
      . Every GTID transaction in
          the binary log is preceded by a
      <code class="literal">
       Gtid_log_event
      </code>
      . A GTID transaction can be
          addressed either by its GTID, or by the name of the file in
          which it is logged and its position within that file.
     </p>
    </li>
    <li class="listitem">
     <p>
      An anonymous transaction has no GTID; MySQL 8.4
          ensures that every anonymous transaction in a log is preceded
          by an
      <code class="literal">
       Anonymous_gtid_log_event
      </code>
      . (In old
          versions of MySQL, an anonymous transaction was not preceded
          by any particular event.) An anonymous transaction can be
          addressed by file name and position only.
     </p>
    </li>
   </ul>
  </div>
  <p>
   When using GTIDs you can take advantage of GTID auto-positioning
      and automatic failover, and use
   <a class="link" href="gtid-functions.html#function_wait-for-executed-gtid-set">
    <code class="literal">
     WAIT_FOR_EXECUTED_GTID_SET()
    </code>
   </a>
   ,
   <a class="link" href="server-system-variables.html#sysvar_session_track_gtids">
    <code class="literal">
     session_track_gtids
    </code>
   </a>
   , and
      Performance Schema tables to monitor replicated transactions (see
   <a class="xref" href="performance-schema-replication-tables.html" title="29.12.11 Performance Schema Replication Tables">
    Section 29.12.11, “Performance Schema Replication Tables”
   </a>
   ).
  </p>
  <p>
   A transaction in a relay log from a source running a previous
      version of MySQL might not be preceded by any particular event,
      but after being replayed and recorded in the replica's binary
      log, it is preceded with an
   <code class="literal">
    Anonymous_gtid_log_event
   </code>
   .
  </p>
  <p>
   To change the replication mode online, it is necessary to set the
   <a class="link" href="replication-options-gtids.html#sysvar_gtid_mode">
    <code class="literal">
     gtid_mode
    </code>
   </a>
   and
   <a class="link" href="replication-options-gtids.html#sysvar_enforce_gtid_consistency">
    <code class="literal">
     enforce_gtid_consistency
    </code>
   </a>
   variables using an account that has privileges sufficient to set
      global system variables; see
   <a class="xref" href="system-variable-privileges.html" title="7.1.9.1 System Variable Privileges">
    Section 7.1.9.1, “System Variable Privileges”
   </a>
   . Permitted values for
   <a class="link" href="replication-options-gtids.html#sysvar_gtid_mode">
    <code class="literal">
     gtid_mode
    </code>
   </a>
   are listed here, in
      order, with their meanings:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <code class="literal">
       OFF
      </code>
      : Only anonymous transactions can be
          replicated.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       OFF_PERMISSIVE
      </code>
      : New transactions are
          anonymous; replicated transactions may be either GTID or
          anonymous.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       ON_PERMISSIVE
      </code>
      : New transactions use GTIDs;
          replicated transactions may be either GTID or anonymous.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       ON
      </code>
      : All transaction must have GTIDs;
          anonymous transactions cannot be replicated.
     </p>
    </li>
   </ul>
  </div>
  <p>
   It is possible to have servers using anonymous and servers using
      GTID transactions in the same replication topology. For example, a
      source where
   <a class="link" href="replication-options-gtids.html#sysvar_gtid_mode">
    <code class="literal">
     gtid_mode=ON
    </code>
   </a>
   can
      replicate to a replica where
   <a class="link" href="replication-options-gtids.html#sysvar_gtid_mode">
    <code class="literal">
     gtid_mode=ON_PERMISSIVE
    </code>
   </a>
   .
  </p>
  <p>
   Replication from a source using
   <a class="link" href="replication-options-gtids.html#sysvar_gtid_mode">
    <code class="literal">
     gtid_mode=ON
    </code>
   </a>
   provides the ability
      to use GTID auto-positioning, configured using the
   <a class="link" href="change-replication-source-to.html#crs-opt-source_auto_position">
    <code class="literal">
     SOURCE_AUTO_POSITION
    </code>
   </a>
   option of
      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. The replication topology in use has an impact on
      whether it is possible to enable auto-positioning or not, since
      this feature relies on GTIDs and is not compatible with anonymous
      transactions. It is strongly recommended to ensure there are no
      anonymous transactions remaining in the topology before enabling
      auto-positioning; see
   <a class="xref" href="replication-mode-change-online-enable-gtids.html" title="19.1.4.2 Enabling GTID Transactions Online">
    Section 19.1.4.2, “Enabling GTID Transactions Online”
   </a>
   .
  </p>
  <p>
   Valid combinations of
   <a class="link" href="replication-options-gtids.html#sysvar_gtid_mode">
    <code class="literal">
     gtid_mode
    </code>
   </a>
   and auto-positioning on source and replica are shown in the next
      table. The meaning of each entry is as follows:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <code class="literal">
       Y
      </code>
      : The values of
      <a class="link" href="replication-options-gtids.html#sysvar_gtid_mode">
       <code class="literal">
        gtid_mode
       </code>
      </a>
      on the source and
          on the replica are compatible.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       N
      </code>
      : The values of
      <a class="link" href="replication-options-gtids.html#sysvar_gtid_mode">
       <code class="literal">
        gtid_mode
       </code>
      </a>
      on the source and
          on the replica are not compatible.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       *
      </code>
      : Auto-positioning can be used with this
          combination of values.
     </p>
    </li>
   </ul>
  </div>
  <div class="table">
   <a name="idm46045145553584">
   </a>
   <p class="title">
    <b>
     Table 19.1 Valid Combinations of Source and Replica gtid_mode
    </b>
   </p>
   <div class="table-contents">
    <table summary="Explains compatible (Y) and incompatible (N) combinations of source and replica GTID mode. An asterisk (*) indicates that auto-positioning can be used with this combination of GTID modes.">
     <colgroup>
      <col style="width: 26%"/>
      <col style="width: 12%"/>
      <col style="width: 24%"/>
      <col style="width: 24%"/>
      <col style="width: 12%"/>
     </colgroup>
     <thead>
      <tr>
       <th scope="col">
        <p>
         <a class="link" href="replication-options-gtids.html#sysvar_gtid_mode">
          <code class="literal">
           gtid_mode
          </code>
         </a>
        </p>
       </th>
       <th scope="col">
        <p>
         Source
         <code class="literal">
          OFF
         </code>
        </p>
       </th>
       <th scope="col">
        <p>
         Source
         <code class="literal">
          OFF_PERMISSIVE
         </code>
        </p>
       </th>
       <th scope="col">
        <p>
         Source
         <code class="literal">
          ON_PERMISSIVE
         </code>
        </p>
       </th>
       <th scope="col">
        <p>
         Source
         <code class="literal">
          ON
         </code>
        </p>
       </th>
      </tr>
     </thead>
     <tbody>
      <tr>
       <th scope="row">
        <p>
         Replica
         <code class="literal">
          OFF
         </code>
        </p>
       </th>
       <td>
        <p>
         Y
        </p>
       </td>
       <td>
        <p>
         Y
        </p>
       </td>
       <td>
        <p>
         N
        </p>
       </td>
       <td>
        <p>
         N
        </p>
       </td>
      </tr>
      <tr>
       <th scope="row">
        <p>
         Replica
         <code class="literal">
          OFF_PERMISSIVE
         </code>
        </p>
       </th>
       <td>
        <p>
         Y
        </p>
       </td>
       <td>
        <p>
         Y
        </p>
       </td>
       <td>
        <p>
         Y
        </p>
       </td>
       <td>
        <p>
         Y*
        </p>
       </td>
      </tr>
      <tr>
       <th scope="row">
        <p>
         Replica
         <code class="literal">
          ON_PERMISSIVE
         </code>
        </p>
       </th>
       <td>
        <p>
         Y
        </p>
       </td>
       <td>
        <p>
         Y
        </p>
       </td>
       <td>
        <p>
         Y
        </p>
       </td>
       <td>
        <p>
         Y*
        </p>
       </td>
      </tr>
      <tr>
       <th scope="row">
        <p>
         Replica
         <code class="literal">
          ON
         </code>
        </p>
       </th>
       <td>
        <p>
         N
        </p>
       </td>
       <td>
        <p>
         N
        </p>
       </td>
       <td>
        <p>
         Y
        </p>
       </td>
       <td>
        <p>
         Y*
        </p>
       </td>
      </tr>
     </tbody>
    </table>
   </div>
  </div>
  <br class="table-break"/>
  <p>
   The current value of
   <a class="link" href="replication-options-gtids.html#sysvar_gtid_mode">
    <code class="literal">
     gtid_mode
    </code>
   </a>
   also affects
   <a class="link" href="replication-options-gtids.html#sysvar_gtid_next">
    <code class="literal">
     gtid_next
    </code>
   </a>
   . The next
      table shows the behavior of the server for combinations of
      different values of
   <a class="link" href="replication-options-gtids.html#sysvar_gtid_mode">
    <code class="literal">
     gtid_mode
    </code>
   </a>
   and
   <a class="link" href="replication-options-gtids.html#sysvar_gtid_next">
    <code class="literal">
     gtid_next
    </code>
   </a>
   . The meaning of each
      entry is as follows:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <code class="literal">
       ANONYMOUS
      </code>
      : Generate an anonymous
          transaction.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       Error
      </code>
      : Generate an error, and do not
          execute
      <code class="literal">
       SET GTID_NEXT
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       UUID:NUMBER
      </code>
      : Generate a GTID with the
          specified UUID:NUMBER.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       UUID:TAG:NUMBER
      </code>
      : Generate a GTID with the
          specified UUID:TAG:NUMBER.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       New GTID
      </code>
      : Generate a GTID with an
          automatically generated number.
     </p>
    </li>
   </ul>
  </div>
  <div class="table">
   <a name="idm46045145497024">
   </a>
   <p class="title">
    <b>
     Table 19.2 Valid Combinations of gtid_mode and gtid_next
    </b>
   </p>
   <div class="table-contents">
    <table summary="Explains the behavior for each of the possible combinations of GTID mode and setting for the gtid_next variable. With gtid_next set to AUTOMATIC, the behavior also varies depending on whether binary logging is enabled or disabled.">
     <colgroup>
      <col style="width:16%"/>
      <col style="width:14%"/>
      <col style="width:14%"/>
      <col style="width:14%"/>
      <col style="width:14%"/>
      <col style="width:14%"/>
      <col style="width:14%"/>
     </colgroup>
     <thead>
      <tr>
       <th scope="col">
       </th>
       <th scope="col">
        <code class="literal">
         gtid_next
        </code>
        =
        <code class="literal">
         AUTOMATIC
        </code>
        (binary log
            on)
       </th>
       <th scope="col">
        <code class="literal">
         gtid_next
        </code>
        =
        <code class="literal">
         AUTOMATIC
        </code>
        (binary log
            off)
       </th>
       <th scope="col">
        <code class="literal">
         gtid_next
        </code>
        =
        <code class="literal">
         AUTOMATIC:&lt;TAG&gt;
        </code>
       </th>
       <th scope="col">
        <code class="literal">
         gtid_next
        </code>
        =
        <code class="literal">
         ANONYMOUS
        </code>
       </th>
       <th scope="col">
        <code class="literal">
         gtid_next
        </code>
        =
        <code class="literal">
         &lt;UUID&gt;:&lt;NUMBER&gt;
        </code>
       </th>
       <th scope="col">
        <code class="literal">
         gtid_next
        </code>
        =
        <code class="literal">
         &lt;UUID&gt;:&lt;TAG&gt;:&lt;NUMBER&gt;
        </code>
       </th>
      </tr>
     </thead>
     <tbody>
      <tr>
       <th scope="row">
        <code class="literal">
         gtid_mode
        </code>
        =
        <code class="literal">
         OFF
        </code>
       </th>
       <td>
        ANONYMOUS
       </td>
       <td>
        ANONYMOUS
       </td>
       <td>
        Error
       </td>
       <td>
        ANONYMOUS
       </td>
       <td>
        Error
       </td>
       <td>
        Error
       </td>
      </tr>
      <tr>
       <th scope="row">
        <code class="literal">
         gtid_mode
        </code>
        =
        <code class="literal">
         OFF_PERMISSIVE
        </code>
       </th>
       <td>
        ANONYMOUS
       </td>
       <td>
        ANONYMOUS
       </td>
       <td>
        Error
       </td>
       <td>
        ANONYMOUS
       </td>
       <td>
        &lt;UUID&gt;:&lt;NUMBER&gt;
       </td>
       <td>
        &lt;UUID&gt;:&lt;TAG&gt;:&lt;NUMBER&gt;
       </td>
      </tr>
      <tr>
       <th scope="row">
        <code class="literal">
         gtid_mode
        </code>
        =
        <code class="literal">
         ON_PERMISSIVE
        </code>
       </th>
       <td>
        New GTID
       </td>
       <td>
        ANONYMOUS
       </td>
       <td>
        New GTID
       </td>
       <td>
        ANONYMOUS
       </td>
       <td>
        &lt;UUID&gt;:&lt;NUMBER&gt;
       </td>
       <td>
        &lt;UUID&gt;:&lt;TAG&gt;:&lt;NUMBER&gt;
       </td>
      </tr>
      <tr>
       <th scope="row">
        <code class="literal">
         gtid_mode
        </code>
        =
        <code class="literal">
         ON
        </code>
       </th>
       <td>
        New GTID
       </td>
       <td>
        ANONYMOUS
       </td>
       <td>
        New GTID
       </td>
       <td>
        Error
       </td>
       <td>
        &lt;UUID&gt;:&lt;NUMBER&gt;
       </td>
       <td>
        &lt;UUID&gt;:&lt;TAG&gt;:&lt;NUMBER&gt;
       </td>
      </tr>
     </tbody>
    </table>
   </div>
  </div>
  <br class="table-break"/>
  <p>
   When binary logging is not in use and
   <a class="link" href="replication-options-gtids.html#sysvar_gtid_next">
    <code class="literal">
     gtid_next
    </code>
   </a>
   is
   <code class="literal">
    AUTOMATIC
   </code>
   , then no GTID is generated.
  </p>
 </div>
 <br/>
</div>
