Mysql database deadlock _ MySQL

Source: Internet
Author: User
Tags sql error
When we frequently insert or update databases, SQL error 1205: lockwaittimeoutexceeded may be reported directly. Database deadlock. Generally, INNODB databases automatically add transactions. when we insert or update a database, if we insert or update the database frequently, the SQL error 1205 may be reported directly: lock wait timeout exceeded. Database deadlock.

Generally, the INNODB database automatically adds transactions. when a transaction is inserted or updated, the system reports an SQL error 1205 if the last commit has not been completed and a new commit is submitted: lock wait timeout exceeded. This is the mysql deadlock.

As a newbie, it is naturally helpless to encounter such a hard task. So I quickly went online and looked at the solution. I did not expect it. on the Internet, I found the corresponding solution and gave three solutions:

1 emergency solution: simple and violent show processlist; then, check which process caused the deadlock and kill it directly.

2 radical solution: select * from innodb_trx check that the transactions occupy the resources. (this solution is no longer available here. how about it? It is also irresponsible ).

3. set the wait timeout: innodb_lock_wait_timeout = 50, autocommit = on. it looks good to set the wait timeout scheme. but just as carefully, how much do you set? What if tens of thousands of data entries are updated every time? I suddenly felt that the feasibility was not high. The second one is not finished. Only the first type of simple violence can be selected.

Later, I consulted the database director. he recommended a solution for me: disable the index first, disable it, disable automatic submission, and then disable the database log. Then he gave me the operation again (of course I didn't learn it), but it was really helpful. I suggest you try it.

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.