<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="replication-functions-synchronization">
      </a>
      14.18.4 Position-Based Synchronization Functions
     </h3>
    </div>
   </div>
  </div>
  <p>
   The functions listed in this section are used for controlling
        position-based synchronization of source and replica servers in
        MySQL Replication.
  </p>
  <div class="table">
   <a name="idm46045193458912">
   </a>
   <p class="title">
    <b>
     Table 14.28 Positional Synchronization Functions
    </b>
   </p>
   <div class="table-contents">
    <table frame="box" rules="all" summary="A reference that lists functions used with position-based synchronization of replication source and replica servers.">
     <colgroup>
      <col style="width: 25%"/>
      <col style="width: 62%"/>
      <col style="width: 12%"/>
     </colgroup>
     <thead>
      <tr>
       <th>
        Name
       </th>
       <th>
        Description
       </th>
       <th>
        Deprecated
       </th>
      </tr>
     </thead>
     <tbody>
      <tr>
       <th scope="row">
        <a class="link" href="replication-functions-synchronization.html#function_master-pos-wait">
         <code class="literal">
          MASTER_POS_WAIT()
         </code>
        </a>
       </th>
       <td>
        Block until the replica has read and applied all updates up to the
      specified position
       </td>
       <td>
        Yes
       </td>
      </tr>
      <tr>
       <th scope="row">
        <a class="link" href="replication-functions-synchronization.html#function_source-pos-wait">
         <code class="literal">
          SOURCE_POS_WAIT()
         </code>
        </a>
       </th>
       <td>
        Block until the replica has read and applied all updates up to the
      specified position
       </td>
       <td>
       </td>
      </tr>
     </tbody>
    </table>
   </div>
  </div>
  <br class="table-break"/>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <a name="function_master-pos-wait">
     </a>
     <p>
      <a class="link" href="replication-functions-synchronization.html#function_master-pos-wait">
       <code class="literal">
        MASTER_POS_WAIT(
        <em class="replaceable">
         <code>
          log_name
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          log_pos
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          timeout
         </code>
        </em>
        ][,
        <em class="replaceable">
         <code>
          channel
         </code>
        </em>
        ])
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045193436720">
     </a>
     <p>
      Deprecated alias for
      <a class="link" href="replication-functions-synchronization.html#function_source-pos-wait">
       <code class="literal">
        SOURCE_POS_WAIT()
       </code>
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <a name="function_source-pos-wait">
     </a>
     <p>
      <a class="link" href="replication-functions-synchronization.html#function_source-pos-wait">
       <code class="literal">
        SOURCE_POS_WAIT(
        <em class="replaceable">
         <code>
          log_name
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          log_pos
         </code>
        </em>
        [,
        <em class="replaceable">
         <code>
          timeout
         </code>
        </em>
        ][,
        <em class="replaceable">
         <code>
          channel
         </code>
        </em>
        ])
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045193426192">
     </a>
     <p>
      This function is for control of source-replica
            synchronization. It blocks until the replica has read and
            applied all updates up to the specified position in the
            source's binary log.
     </p>
     <p>
      The return value is the number of log events the replica had
            to wait for to advance to the specified position. The
            function returns
      <code class="literal">
       NULL
      </code>
      if the replication
            SQL thread is not started, the replica's source information
            is not initialized, the arguments are incorrect, or an error
            occurs. It returns
      <code class="literal">
       -1
      </code>
      if the timeout has
            been exceeded. If the replication SQL thread stops while
      <a class="link" href="replication-functions-synchronization.html#function_source-pos-wait">
       <code class="literal">
        SOURCE_POS_WAIT()
       </code>
      </a>
      is waiting,
            the function returns
      <code class="literal">
       NULL
      </code>
      . If the replica
            is past the specified position, the function returns
            immediately.
     </p>
     <p>
      If the binary log file position has been marked as invalid,
            the function waits until a valid file position is known. The
            binary log file position can be marked as invalid when 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>
      option
      <code class="literal">
       GTID_ONLY
      </code>
      is set for the
            replication channel, and the server is restarted or
            replication is stopped. The file position becomes valid
            after a transaction is successfully applied past the given
            file position. If the applier does not reach the stated
            position, the function waits until the timeout. Use a
      <a class="link" href="show-replica-status.html" title="15.7.7.35 SHOW REPLICA STATUS Statement">
       <code class="literal">
        SHOW REPLICA STATUS
       </code>
      </a>
      statement
            to check if the binary log file position has been marked as
            invalid.
     </p>
     <p>
      On a multithreaded replica, the function waits until expiry
            of the limit set by the
      <a class="link" href="replication-options-replica.html#sysvar_replica_checkpoint_group">
       <code class="literal">
        replica_checkpoint_group
       </code>
      </a>
      or
      <a class="link" href="replication-options-replica.html#sysvar_replica_checkpoint_period">
       <code class="literal">
        replica_checkpoint_period
       </code>
      </a>
      system variable, when the checkpoint operation is called to
            update the status of the replica. Depending on the setting
            for the system variables, the function might therefore
            return some time after the specified position was reached.
     </p>
     <p>
      If binary log transaction compression is in use and the
            transaction payload at the specified position is compressed
            (as a
      <code class="literal">
       Transaction_payload_event
      </code>
      ), the
            function waits until the whole transaction has been read and
            applied, and the positions have updated.
     </p>
     <p>
      If a
      <em class="replaceable">
       <code>
        timeout
       </code>
      </em>
      value is specified,
      <a class="link" href="replication-functions-synchronization.html#function_source-pos-wait">
       <code class="literal">
        SOURCE_POS_WAIT()
       </code>
      </a>
      stops
            waiting when
      <em class="replaceable">
       <code>
        timeout
       </code>
      </em>
      seconds have
            elapsed.
      <em class="replaceable">
       <code>
        timeout
       </code>
      </em>
      must be greater
            than or equal to 0. (When the server is running in strict
            SQL mode, a negative
      <em class="replaceable">
       <code>
        timeout
       </code>
      </em>
      value is immediately rejected with
      <a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_wrong_arguments" target="_top">
       <code class="literal">
        ER_WRONG_ARGUMENTS
       </code>
      </a>
      ;
            otherwise the function returns
      <code class="literal">
       NULL
      </code>
      , and
            raises a warning.)
     </p>
     <p>
      The optional
      <em class="replaceable">
       <code>
        channel
       </code>
      </em>
      value
            enables you to name which replication channel the function
            applies to. See
      <a class="xref" href="replication-channels.html" title="19.2.2 Replication Channels">
       Section 19.2.2, “Replication Channels”
      </a>
      for
            more information.
     </p>
     <p>
      This function is unsafe for statement-based replication. A
            warning is logged if you use this function when
      <a class="link" href="replication-options-binary-log.html#sysvar_binlog_format">
       <code class="literal">
        binlog_format
       </code>
      </a>
      is set to
      <code class="literal">
       STATEMENT
      </code>
      .
     </p>
    </li>
   </ul>
  </div>
 </div>
 <br/>
</div>
