MySql 的隔离级别是可重复读
CREATE TABLE `t` (
`id` int(11) NOT NULL,
`c` int(11) DEFAULT NULL,
`d` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `c` (`c`)
) ENGINE=InnoDB;
insert into t values(0,0,0),(5,5,5),
(10,10,10),(15,15,15),(20,20,20),(25,25,25);
| sessionA | sessionB |
|---|---|
| begin; | |
| select * from t where c >=15 and c<=20 order by c desc for update; | |
| insert into t (6,6,6); |
为什么 sessionB 会阻塞? 为什么在索引 c 上向左遍历,要扫描到 c=10 才停下来,next-key lock 会加到(5,10]? 求解答