MySQL Database deadlock

Source: Internet
Author: User

when we frequently insert or update the database, it is possible to directly report SQL error 1205:lock wait timeout exceeded. The deadlock of the database.

General InnoDB Database will automatically add transactions, when inserting or updating, if the last commit has not been completed, and a new commit commits, the system will report a SQL error 1205:lock wait timeout Exceeded. This is the MySQL deadlock.

As a novice, it is natural to encounter such hard-pressed things. So hurriedly online to see solution, not negative hope, online also really find the corresponding ending plan, and gave three kinds:

1 Contingency plan: simple violence show Processlist and then see which process caused the deadlock and kill it directly.

2 Radical Solution: SELECT * from Innodb_trx view is that those transactions occupy the resources (this scheme says there is no then, and the view is done?) Lying trough, is also irresponsible).

3 Set Wait timeout: Innodb_lock_wait_timeout=50,autocommit=on. Set wait timeout the scheme looks good, but as you are careful, how much do you set? What if we update tens of thousands of data each time, what's the slow one? Suddenly the sense of feasibility is not high. The second kind, not at all after the end of the forget. Can only choose the first kind of simple violence.

Later I consulted the database of the great God, he gave me a proposal: Disable the index, then close, then close autocommit, and then close the database log. Then he gave me the operation (of course I did not learn), but really good, suggest will use can try.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

MySQL Database deadlock

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.