我在解决LOCK WAIT TIMEOUT EXCEED
MySQL InnoDB 错误时遇到了麻烦。
我已经阅读了这篇文章,它说如果我们使用隔离级别READ_COMMITTED
,那么我的更新查询应该只锁定那些匹配WHERE
条件的行,但这对我不起作用,因为我正在54
为该查询获取行锁。
结果SHOW ENGINE INNODB STATUS;
如下。
---TRANSACTION 8AE162608, ACTIVE 102 sec starting index read
mysql tables in use 1, locked 1
LOCK WAIT 56 lock struct(s), heap size 6960, 54 row lock(s), undo log entries 135
MySQL thread id 18013536, query id 164766412915 localhost MyDataDb Updating
update stock set quantity = quantity + -1, last_updated_dts='2015-01-19 00:08:23', last_updated_by='vishal' where location = 1 and product_id = '123'
------- TRX HAS BEEN WAITING 98 SEC FOR THIS LOCK TO BE GRANTED:
为什么我的更新查询条件仅匹配一行并且我使用隔离级别时锁定了54行?READ_COMMITED