After the mysqlinnodb row locks are unlocked, the 1213 dead performance is like Deadlockfoundwhen solving bitsCN.com.
After the mysql innodb row lock is unlocked, the system displays the 1213 dead result, which is like the Deadlock found when solution.
Remember that the row locks and locks of innodb 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 may be returned in the program.
Instance:
Table
Soldgoods (table name)
SoldgoodsID index
Productid
Businessid
Enable thread
Run:
Set autocommit = 0;
Select businessid from soldgoods where soldgoodsID = 'ac63837c76222e4a5419e2529d775ae4 'for UPDATE;
Query Results
Enable thread B
Run:
Set autocommit = 0;
Select businessid from soldgoods where soldgoodsID = 'ac63837c76222e4a5419e2529d775ae4 'for UPDATE;
Query waiting to unlock
At this time, execute in thread:
Update soldgoods set productid = 2 where businessid = '0a527df4763c3dc71cbafebec5a8d787'
Instead of updating the lock table value based on the primary key
Thread B appears:
[Err] 1213-Deadlock found when trying to get lock; try restarting transaction
If the statement executed in the last thread A is changed:
Update soldgoods set productid = 2 where soldgoodsID = 'ac63837c76222e4a5419e2529d775ae4'
Modify value based on index
Then
Commit;
Commit a transaction. Thread B can get the query value smoothly.
BitsCN.com