示例

行锁-InnoDB

  1. create table rlock(a int(10) unsigned not null auto_increment primary key)engine=InnoDB;
  2. insert into rlock(a) values(1),(2),(3);
  3. insert into rlock select null from rlock;

session1:
image.png
image.png

关于innodb 行锁超时时间的设置https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_lock_wait_timeout

session2:
行锁 - 图3
session3:
注意:Id-10的查询状态为updating而不是locked
image.png

验证InnoDB引擎中是否有一个请求阻塞

show engine innodb status\G

image.png