After the mysql innodb row lock is unlocked, the system displays the 1213 dead result, which is like the Deadlock found when solution.

Source: Internet
Author: User

After the mysql innodb row lock is unlocked, the result is 1213 dead, like Deadlock found when. To solve this problem, remember that innodb row locks and locks are for primary key indexes. If the table is locked Based on the index during the query, but it is not updated through the primary key during the update, the process waiting to unlock the query will report a 1213 error, and a null value instance may be returned in the program: table soldgoods (table Name) soldgoodsID index productid businessid enable thread A execution: set autocommit = 0; select businessid from soldgoods where soldgoodsID = 'hangzhou' for UPDATE; run thread B on the query result: set autocommit = 0; select businessid from soldgoods where soldgoodsID = 'hangzhou' for UPDATE; run updat in thread A when the query is waiting to be unlocked. E soldgoods set productid = 2 where businessid = 'taobao' is not used to update the lock Table value based on the primary key. Thread B will appear: [Err] 1213-Deadlock found when trying to get lock; try restarting transaction if you change the statement executed in the last thread A: update soldgoods set productid = 2 where soldgoodsID = 'ac63837c76222e4a5419e2529d775ae4 'based on the index modification value, then commit. Thread B can get the query value smoothly.

Related Article

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.