innodb 锁处理

innodb 锁处理
当两个事务对同一资源时行修改操作时,会对这一资源加上X锁。b的原始值为1140

T1: update t_lock set b = 1143 where id = 1;没有执行commit
T2: update t_lock set b = 1145 where id = 1;操作会因为执行超时而抛出异常:

Lock wait timeout exceeded; try restarting transaction

# 因为T2在等待T1执行commit,释放资源。因为T1一直没有commit,所以导致了T2的超时。这里可以看做是T1被T2阻塞了。