<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="replication-solutions-rbr-monitoring">
      </a>
      19.4.3 Monitoring Row-based Replication
     </h3>
    </div>
   </div>
  </div>
  <p>
   The current progress of the replication applier (SQL) thread when
      using row-based replication is monitored through Performance
      Schema instrument stages, enabling you to track the processing of
      operations and check the amount of work completed and work
      estimated. When these Performance Schema instrument stages are
      enabled the
   <a class="link" href="performance-schema-events-stages-current-table.html" title="29.12.5.1 The events_stages_current Table">
    <code class="literal">
     events_stages_current
    </code>
   </a>
   table shows stages for applier threads and their progress. For
      background information, see
   <a class="xref" href="performance-schema-stage-tables.html" title="29.12.5 Performance Schema Stage Event Tables">
    Section 29.12.5, “Performance Schema Stage Event Tables”
   </a>
   .
  </p>
  <p>
   To track progress of all three row-based replication event types
      (write, update, delete):
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Enable the three Performance Schema stages by issuing:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa11639495"><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">UPDATE</span> performance_schema<span class="token punctuation">.</span>setup_instruments <span class="token keyword">SET</span> ENABLED <span class="token operator">=</span> <span class="token string">'YES'</span>
<span class="token prompt">    -&gt;</span> <span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'stage/sql/Applying batch of row changes%'</span><span class="token punctuation">;</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Wait for some events to be processed by the replication
          applier thread and then check progress by looking into the
      <a class="link" href="performance-schema-events-stages-current-table.html" title="29.12.5.1 The events_stages_current Table">
       <code class="literal">
        events_stages_current
       </code>
      </a>
      table. For
          example to get progress for
      <code class="literal">
       update
      </code>
      events
          issue:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa47589566"><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> WORK_COMPLETED<span class="token punctuation">,</span> WORK_ESTIMATED <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>events_stages_current
<span class="token prompt">    -&gt;</span> <span class="token keyword">WHERE</span> EVENT_NAME <span class="token operator">LIKE</span> <span class="token string">'stage/sql/Applying batch of row changes (update)'</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      If
      <a class="link" href="replication-options-binary-log.html#sysvar_binlog_rows_query_log_events">
       <code class="literal">
        binlog_rows_query_log_events
       </code>
      </a>
      is enabled, information about queries is stored in the binary
          log and is exposed in the
      <code class="literal">
       processlist_info
      </code>
      field. To see the original query that triggered this event:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa78733572"><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> db<span class="token punctuation">,</span> processlist_state<span class="token punctuation">,</span> processlist_info <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>threads
<span class="token prompt">    -&gt;</span> <span class="token keyword">WHERE</span> processlist_state <span class="token operator">LIKE</span> <span class="token string">'stage/sql/Applying batch of row changes%'</span> <span class="token operator">AND</span> thread_id <span class="token operator">=</span> N<span class="token punctuation">;</span></code></pre>
     </div>
    </li>
   </ul>
  </div>
 </div>
 <br/>
</div>
