想自己测试下间隙锁现象,于是就按照一些博客上的步骤操作,结果并没有出现什么间隙锁的现象,有谁遇到过吗?
下面是操作步骤:
CREATE TABLE test
.user (
id
int(11) NOT NULL,
name
varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
age
int(11) NULL DEFAULT NULL,
PRIMARY KEY (id
) USING BTREE,
INDEX index_age
(age
) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
插入数据
1 xiaoming 12
3 xiaohong 20
5 laowang 36
开启两个事务
session1;
start transaction;
select * fro m yser where age=20; 在普通索引 age上加锁 按说会锁住 12,20 20,20 20,36区间
session2
start transaction;
insert into user values(null,"zhangsan",15);
结果session2中的insert语句应该阻塞才对 但是却执行成功了
另外间隙锁测参数已经是开启了