【发布时间】:2015-08-04 04:01:24
【问题描述】:
我在使用 MySQL InnoDB 解决 LOCK WAIT TIMEOUT EXCEED 错误时遇到了麻烦。
我已经完成了this article,它说如果我们使用隔离级别READ_COMMITTED,那么我的更新查询应该只锁定那些匹配WHERE 条件的行,但这对我不起作用,因为我得到@ 987654325@ 该查询的行锁。
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:
为什么我的更新查询条件只匹配 一行 并且我使用 READ_COMMITED 隔离级别时锁定了 54 行?
【问题讨论】:
标签: mysql locking innodb rowlocking read-committed