How to solve the MySQL deadlock problem (1) [memo]

Source: Internet
Author: User

If a deadlock occurs, use the show InnoDB STATUS Command to determine the cause of the last deadlock. The returned results contain detailed information about deadlocked transactions, such as SQL statements that cause deadlocked transactions, locks that the transactions have obtained, locks waiting for, and rollback transactions. The cause of the deadlock and the improvement measures can be analyzed accordingly. The following is an example of the show InnoDB status output:

 
Mysql> show InnoDB status/g
.......
------------------------
Latest detected deadlock
------------------------
14:05:16 070710
* ** (1) transaction:
Transaction 0 117470078, active 117 sec, process no 1468, OS
Thread ID 1197328736 inserting
MySQL tables in use 1, locked 1
Lock wait 5 lock struct (s) and heap size 1216
MySQL thread ID 7521657, query ID 673468054 localhost root update
Insert into country (country_id, country) values (110, 'test ')
.........
* ** (2) transaction:
Transaction 0 117470079, active 39 sec, process no 1468, OS
Thread ID 1164048736 starting index read, thread declared inside InnoDB 500
MySQL tables in use 1, locked 1
4 lock struct (s), heap size 1216, UNDO log entries 1
MySQL thread ID 7521664 and query ID 673468058 localhost root statistics
Select first_name, last_name from actor where actor_id = 1 for update
* ** (2) holds the lock (s ):
.........
 
* ** (2) waiting for this lock to be granted:
.........
 
* ** We roll back transaction (1)
......

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.