The client returns this error: ERROR 1213 (40001): Deadlock found when trying to get lock Īt that point, the lock request for the other client can be granted and it deletes the row from the table. As a result, InnoDB generates an error for one of the clients and releases its locks. Nor can the S lock held by A be upgraded to an X lock because of the prior request by B for an X lock. However, that lock request cannot be granted because client B already has a request for an X lock and is waiting for client A to release its S lock. The lock cannot be granted because it is incompatible with the S lock that client A holds, so the request goes on the queue of lock requests for the row and client B blocks.įinally, client A also attempts to delete the row from the table: mysql> DELETE FROM t WHERE i = 1 ĮRROR 1213 (40001): Deadlock found when trying to get lock ĭeadlock occurs here because client A needs an X lock to delete the row. Next, client B begins a transaction and attempts to delete the row from the table: Mysql> SELECT * FROM t WHERE i = 1 FOR SHARE A deadlock example is as follows: mysql> CREATE TABLE t (i INT) ENGINE = InnoDB A deadlock can also occur when such statements lock ranges of index records and gaps, with each transaction acquiring some locks but not others due to a timing issue. Because both transactions are waiting for a resource to become available, neither ever release the locks it holds.Ī deadlock can occur when transactions lock rows in multiple tables (through statements such as UPDATE or SELECT … FOR UPDATE), but in the opposite order. A deadlock is a situation where different transactions are unable to proceed because each holds a lock that the other needs.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |