Bug #57118 | Undetected deadlock with select for update on a InnoDB + MyISAM join | ||
---|---|---|---|
Submitted: | 30 Sep 2010 0:51 | Modified: | 30 Sep 2010 6:41 |
Reporter: | Andrew Pimlott | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Locking | Severity: | S3 (Non-critical) |
Version: | 5.1.49, 5.1.52-bzr | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | deadlock |
[30 Sep 2010 0:51]
Andrew Pimlott
[30 Sep 2010 6:41]
Valeriy Kravchuk
Verified as described with current mysql-5.1 from bzr on Ubuntu. This is what we can see in "mysqladmin debug" output: Thread database.table_name Locked/Waiting Lock_type 1 test.isam Waiting - write High priority write lock 2 test.inno Locked - write High priority write lock 2 test.isam Locked - write High priority write lock INNODB STATUS from the 3rd session shows the following: ... ---TRANSACTION 0 3843, ACTIVE 19 sec, process no 1589, OS thread id 3023719280 starting index read mysql tables in use 1, locked 1 LOCK WAIT 2 lock struct(s), heap size 320, 1 row lock(s) MySQL thread id 2, query id 42 localhost root statistics select * from isam join inno on isam.id = inno.id where isam.id = 1 for update ------- TRX HAS BEEN WAITING 19 SEC FOR THIS LOCK TO BE GRANTED: RECORD LOCKS space id 0 page no 1730 n bits 72 index `PRIMARY` of table `test`.`inno` trx id 0 3843 lock_mode X locks rec but not gap waiting Record lock, heap no 2 PHYSICAL RECORD: n_fields 3; compact format; info bits 0 0: len 4; hex 80000001; asc ;; 1: len 6; hex 000000000f01; asc ;; 2: len 7; hex 800000002d0110; asc - ;; ------------------ ---TRANSACTION 0 3842, ACTIVE 26 sec, process no 1589, OS thread id 3023919984 mysql tables in use 1, locked 1 2 lock struct(s), heap size 320, 1 row lock(s) MySQL thread id 1, query id 43 localhost root Table lock select * from isam join inno on isam.id = inno.id where isam.id = 1 for update ... and indeed, with 2 InnoDB tables second session waits, but the first one easily executes the same query again. So it is all about table level locks on MyISAM table used in join.
[30 Sep 2010 20:01]
Konstantin Osipov
A fix: do not take TL_WRITE lock when executing SELECT FOR UPDATE and the underlying engine is MyISAM. We have always been doing that, but we donot document this fact.