Bug #61965 | deadlock simultaneously insert on tbl1 and update on tbl2 from diff tx, innodb | ||
---|---|---|---|
Submitted: | 24 Jul 2011 20:25 | Modified: | 3 Aug 2011 22:41 |
Reporter: | Federico Jakimowicz | Email Updates: | |
Status: | Duplicate | Impact on me: | |
Category: | MySQL Server: Locking | Severity: | S3 (Non-critical) |
Version: | 5.5 | OS: | Windows (XP) |
Assigned to: | CPU Architecture: | Any | |
Tags: | deadlock, innodb, insert, transactions, UPDATE |
[24 Jul 2011 20:25]
Federico Jakimowicz
[25 Jul 2011 3:48]
Valeriy Kravchuk
Does this quote (http://dev.mysql.com/doc/refman/5.5/en/innodb-locks-set.html): "If a FOREIGN KEY constraint is defined on a table, any insert, update, or delete that requires the constraint condition to be checked sets shared record-level locks on the records that it looks at to check the constraint. InnoDB also sets these locks in the case where the constraint fails." explain what happens and why? Side note: there is no need to define UNIQUE INDEX(id) if id is defined as PRIMARY KEY.
[25 Jul 2011 5:26]
Federico Jakimowicz
Hi Valeriy, Thanks a lot for your tip I have been reading on that and also found this one http://dev.mysql.com/doc/refman/5.5/en/innodb-lock-modes.html . So it seems there is no other way than removing the fk, changing the excecution order to perform the updates before de insert or using select for update? kind regards.
[26 Jul 2011 3:15]
Federico Jakimowicz
I have been doing some tests on oracle 10g and this locking issue does not happen. It just put the 2nd tx in wait when attemps to update user. Maybe that would be a more desirable behaviour? I will read more about oracle locking.
[26 Jul 2011 10:45]
Valeriy Kravchuk
Locking in every RDBMS is done differently. Oracle RDBMS does not set read (S, shared) locks on rows at all. InnoDB does, in some cases. I doubt this can be changed.
[3 Aug 2011 22:41]
Sveta Smirnova
Thank you for the feedback. This is duplicate of already verified feature request.