Rechercher dans le manuel MySQL
15.20.4 InnoDB Error Handling
The following items describe how InnoDB
performs error handling. InnoDB
sometimes rolls
back only the statement that failed, other times it rolls back the
entire transaction.
If you run out of file space in a tablespace, a MySQL
Table is full
error occurs andInnoDB
rolls back the SQL statement.A transaction deadlock causes
InnoDB
to roll back the entire transaction. Retry the whole transaction when this happens.A lock wait timeout causes
InnoDB
to roll back only the single statement that was waiting for the lock and encountered the timeout. (To have the entire transaction roll back, start the server with the--innodb-rollback-on-timeout
option.) Retry the statement if using the current behavior, or the entire transaction if using--innodb-rollback-on-timeout
.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.
When a transaction rollback occurs due to a deadlock or lock wait timeout, it cancels the effect of the statements within the transaction. But if the start-transaction statement was
START TRANSACTION
orBEGIN
statement, rollback does not cancel that statement. Further SQL statements become part of the transaction until the occurrence ofCOMMIT
,ROLLBACK
, or some SQL statement that causes an implicit commit.A duplicate-key error rolls back the SQL statement, if you have not specified the
IGNORE
option in your statement.A
row too long error
rolls back the SQL statement.Other errors are mostly detected by the MySQL layer of code (above the
InnoDB
storage engine level), and they roll back the corresponding SQL statement. Locks are not released in a rollback of a single SQL statement.
During implicit rollbacks, as well as during the execution of an
explicit
ROLLBACK
SQL
statement, SHOW PROCESSLIST
displays Rolling back
in the
State
column for the relevant connection.
Document created the 26/06/2006, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/mysql-rf-innodb-error-handling.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.