MySQL Forums
Forum List  »  General

Re: Select for update twice to same table by diffrenet key cause deadlock
Posted by: kouhei toki
Date: December 16, 2017 07:23PM

I figured out close answer.

MySQL locks all records when select for update searched by no indexed column.

>> quote from MySQL manual
https://dev.mysql.com/doc/refman/5.7/en/innodb-locks-set.html

If you have no indexes suitable for your statement and MySQL must scan the entire table to process the statement, every row of the table becomes locked, which in turn blocks all inserts by other users to the table.
<<

But, I don't know why this causes deadlock.

By the way, I resolved my problem that every select for update to search by primary key.

Options: ReplyQuote


Subject
Written By
Posted
Re: Select for update twice to same table by diffrenet key cause deadlock
December 16, 2017 07:23PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.