<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="innodb-error-handling">
      </a>
      17.20.5 InnoDB Error Handling
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045148856544">
  </a>
  <a class="indexterm" name="idm46045148854640">
  </a>
  <p>
   The following items describe how
   <code class="literal">
    InnoDB
   </code>
   performs error handling.
   <code class="literal">
    InnoDB
   </code>
   sometimes rolls
      back only the statement that failed, other times it rolls back the
      entire transaction.
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      If you run out of file space in a
      <a class="link" href="glossary.html#glos_tablespace" title="tablespace">
       tablespace
      </a>
      , a MySQL
      <code class="literal">
       Table is full
      </code>
      error occurs and
      <code class="literal">
       InnoDB
      </code>
      rolls back the SQL statement.
     </p>
    </li>
    <li class="listitem">
     <p>
      A transaction
      <a class="link" href="glossary.html#glos_deadlock" title="deadlock">
       deadlock
      </a>
      causes
      <code class="literal">
       InnoDB
      </code>
      to
      <a class="link" href="glossary.html#glos_rollback" title="rollback">
       roll back
      </a>
      the entire
      <a class="link" href="glossary.html#glos_transaction" title="transaction">
       transaction
      </a>
      . Retry the
          entire transaction when this happens.
     </p>
     <p>
      A lock wait timeout causes
      <code class="literal">
       InnoDB
      </code>
      to roll
          back the current statement (the statement that was waiting for
          the lock and encountered the timeout). To have the entire
          transaction roll back, start the server with
      <a class="link" href="innodb-parameters.html#sysvar_innodb_rollback_on_timeout">
       <code class="option">
        --innodb-rollback-on-timeout
       </code>
      </a>
      enabled. Retry the statement if using the default behavior, or
          the entire transaction if
      <a class="link" href="innodb-parameters.html#sysvar_innodb_rollback_on_timeout">
       <code class="option">
        --innodb-rollback-on-timeout
       </code>
      </a>
      is
          enabled.
     </p>
     <p>
      Both deadlocks and lock wait timeouts are normal on busy
          servers and it is necessary for applications to be aware that
          they may happen and handle them by retrying. You can make them
          less likely by doing as little work as possible between the
          first change to data during a transaction and the commit, so
          the locks are held for the shortest possible time and for the
          smallest possible number of rows. Sometimes splitting work
          between different transactions may be practical and helpful.
     </p>
    </li>
    <li class="listitem">
     <p>
      A duplicate-key error rolls back the SQL statement, if you
          have not specified the
      <code class="literal">
       IGNORE
      </code>
      option in
          your statement.
     </p>
    </li>
    <li class="listitem">
     <p>
      A
      <code class="literal">
       row too long error
      </code>
      rolls back the SQL
          statement.
     </p>
    </li>
    <li class="listitem">
     <p>
      Other errors are mostly detected by the MySQL layer of code
          (above the
      <code class="literal">
       InnoDB
      </code>
      storage engine level),
          and they roll back the corresponding SQL statement. Locks are
          not released in a rollback of a single SQL statement.
     </p>
    </li>
   </ul>
  </div>
  <p>
   During implicit rollbacks, as well as during the execution of an
      explicit
   <a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
    <code class="literal">
     ROLLBACK
    </code>
   </a>
   SQL
      statement,
   <a class="link" href="show-processlist.html" title="15.7.7.31 SHOW PROCESSLIST Statement">
    <code class="literal">
     SHOW PROCESSLIST
    </code>
   </a>
   displays
   <code class="literal">
    Rolling back
   </code>
   in the
   <code class="literal">
    State
   </code>
   column for the relevant connection.
  </p>
 </div>
 <br/>
</div>
