<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="innodb-transaction-scheduling">
      </a>
      17.7.6 Transaction Scheduling
     </h3>
    </div>
   </div>
  </div>
  <p>
   <code class="literal">
    InnoDB
   </code>
   uses the Contention-Aware Transaction
      Scheduling (CATS) algorithm to prioritize transactions that are
      waiting for locks. When multiple transactions are waiting for a
      lock on the same object, the CATS algorithm determines which
      transaction receives the lock first.
  </p>
  <p>
   The CATS algorithm prioritizes waiting transactions by assigning a
      scheduling weight, which is computed based on the number of
      transactions that a transaction blocks. For example, if two
      transactions are waiting for a lock on the same object, the
      transaction that blocks the most transactions is assigned a
      greater scheduling weight. If weights are equal, priority is given
      to the longest waiting transaction.
  </p>
  <p>
   You can view transaction scheduling weights by querying the
   <code class="literal">
    TRX_SCHEDULE_WEIGHT
   </code>
   column in the Information
      Schema
   <a class="link" href="information-schema-innodb-trx-table.html" title="28.4.28 The INFORMATION_SCHEMA INNODB_TRX Table">
    <code class="literal">
     INNODB_TRX
    </code>
   </a>
   table. Weights are
      computed for waiting transactions only. Waiting transactions are
      those in a
   <code class="literal">
    LOCK WAIT
   </code>
   transaction execution
      state, as reported by the
   <code class="literal">
    TRX_STATE
   </code>
   column. A
      transaction that is not waiting for a lock reports a NULL
   <code class="literal">
    TRX_SCHEDULE_WEIGHT
   </code>
   value.
  </p>
  <p>
   <a class="link" href="information-schema-innodb-metrics-table.html" title="28.4.21 The INFORMATION_SCHEMA INNODB_METRICS Table">
    <code class="literal">
     INNODB_METRICS
    </code>
   </a>
   counters are provided
      for monitoring of code-level transaction scheduling events. For
      information about using
   <a class="link" href="information-schema-innodb-metrics-table.html" title="28.4.21 The INFORMATION_SCHEMA INNODB_METRICS Table">
    <code class="literal">
     INNODB_METRICS
    </code>
   </a>
   counters, see
   <a class="xref" href="innodb-information-schema-metrics-table.html" title="17.15.6 InnoDB INFORMATION_SCHEMA Metrics Table">
    Section 17.15.6, “InnoDB INFORMATION_SCHEMA Metrics Table”
   </a>
   .
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <code class="literal">
       lock_rec_release_attempts
      </code>
     </p>
     <p>
      The number of attempts to release record locks. A single
          attempt may lead to zero or more record locks being released,
          as there may be zero or more record locks in a single
          structure.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       lock_rec_grant_attempts
      </code>
     </p>
     <p>
      The number of attempts to grant record locks. A single attempt
          may result in zero or more record locks being granted.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       lock_schedule_refreshes
      </code>
     </p>
     <p>
      The number of times the wait-for graph was analyzed to update
          the scheduled transaction weights.
     </p>
    </li>
   </ul>
  </div>
 </div>
 <br/>
</div>
