14.5.5.2 deadlock detection and Rollback deadlock detection and rollback
InnoDB automatic transaction deadlock and rollback a transaction
InnoDB try to pick a small transaction to roll back and forth, the size of the transaction is Rows inserted, updated, or deleted the number of determined
InnoDB know the table lock if Innodb_table_locks = 1 (the default) and autocommit = 0,
MySQL level knows about row locks
Otherwise, InnoDB cannot detect deadlocks a table table is set through a lock tables statement or set through a storage engine.
solve those problems by setting the value of the Innodb_lock_wait_timeout system variable
when InnoDB performs a full transaction rollback, all locks set by the transaction are freed.
However, if just a separate SQL statement is rolled back as an error result,
Some locks set by the statement may be saved.