Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

CREATE TABLE `b` (
 `a` int(11) NOT NULL,
 `b` int(11) DEFAULT NULL,
 `c` int(11) DEFAULT NULL,
 PRIMARY KEY (`a`),
 UNIQUE KEY `idx_b` (`b`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
insert(1,1,1);
insert(3,3,3);
insert(5,5,5);
insert(10,10,10);
insert(15,15,15);

session 1:
begin;
select * from b where b >= 10 for update;
commit;
根据唯一索引的等值查询会退化成行锁这一前提,计算以上语句对b索引的加锁范围为[10],(10,15],(15,+], 对主键索引为[10],[15]
session 2:
insert(9,9,9); -- 被阻塞,请问这是为什么呢
当把session 1 的 b>= 10 改成 a >= 10后,session 2就可以正常插入.
a是主键,b也是唯一索引,请问这是什么原因,我遗漏了什么知识点

mysql 8.0.12 , rr隔离级别


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
434 views
Welcome To Ask or Share your Answers For Others

1 Answer

是什么隔离级别


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...