MySQL Forums
Forum List  »  InnoDB

Re: deadlock: a row being locked by a query twice?
Posted by: Amit K
Date: April 09, 2016 09:53PM

>Unless I'm missing something in this query, it can be written more efficiently >and perhaps avoid the second lock ...
>
>SELECT *
>FROM `active_user`
>WHERE `user_id`=111111 AND `identifier`='XXXXXXXXXXXXXX@gmail.com' and type >in('1','11','18');
>FOR UPDATE ;

Well, this query was resulting in a lot of (gap lock related) deadlocks.

To fix that I had to switch to a query that uses primary key for locking rows (the query that I have posted in my first post). As given here https://dev.mysql.com/doc/refman/5.7/en/innodb-record-level-locks.html#idm139723103153008

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: deadlock: a row being locked by a query twice?
601
April 09, 2016 09:53PM


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.