当前位置:网站首页>事务隔离级别 gap锁 死锁
事务隔离级别 gap锁 死锁
2022-07-01 18:45:00 【这样の我】
1.事务隔离级别
- 序列化(SERIALIZABLE)
- 可重复读(REPEATABLE READ)
- 提交读(READ COMMITTED)
- 未提交读(READ UNCOMMITTED)
四个隔离级别分别对应增删改查
2.gap锁分析:
未提交读(READ UNCOMMITTED):增删改查不加锁。
提交读(READ COMMITTED):增时锁住索引一段的距离(如添加时索引为12,锁住一段索引在12上下的一段距离),等事务提交时候释放锁。
可重复读(REPEATABLE READ):增删改数据时锁住索引一段距离(insert如上,删改时若索引为12,则锁住上一行以及下一行索引的距离,若没有上一行或者下一行,则锁住一段距离)
序列化(SERIALIZABLE):增删改查都会加锁,事务只能一个一个提交,获取到的事务直接锁表
3.gap 死锁
两个事务同事获得了一段区间锁,且同时操作区间
111 delete from ts_column_log_test wherecol_id=10;
222 delete from ts_column_log_test where col_id=11;
111 INSERT INTO ts_column_log_test (col_id,start_time, end_time, data_time, status) VALUES (10, NULL, NULL, '20111209','running');
222 INSERT INTO ts_column_log_test (col_id, start_time, end_time,data_time, status) VALUES (11, NULL, NULL, '20111209', 'running');
这个时候,你可能就会得到错误提示ERROR 1213 (40001): Deadlock found when trying toget lock; try restarting transaction。
原因是前两条语句都已经获得了[2,20)这个区间内记录的S锁,然后两个事务又分别对该区间段内的col_id=10这个位置请求X锁,这时就发生死锁,谁都请求不到X锁,因为互相都持有S锁。
边栏推荐
- Chaos engineering platform chaosblade box new heavy release
- 118. 杨辉三角
- 使用环信提供的uni-app Demo,快速实现一对一单聊
- ddr4测试-2
- pickle.load报错【AttributeError: Can‘t get attribute ‘Vocabulary‘ on <module ‘__main__‘】
- Summary of SQL query de duplication statistics methods
- [go ~ 0 to 1] day 5 July 1 type alias, custom type, interface, package and initialization function
- EasyGBS网络不稳定情况下重复请求视频拉流问题的优化
- XML syntax, constraints
- Solidity - 算术运算的截断模式(unchecked)与检查模式(checked)- 0.8.0新特性
猜你喜欢

论文阅读【Discriminative Latent Semantic Graph for Video Captioning】

Lake Shore - crx-em-hf low temperature probe station
![Extensive reading of the paper [film: visual reasoning with a general condition layer]](/img/69/f4ba37a7eae34a7e698127c31b0161.png)
Extensive reading of the paper [film: visual reasoning with a general condition layer]

测试自学人必看:软件测试如何找测试项目?

pickle.load报错【AttributeError: Can‘t get attribute ‘Vocabulary‘ on <module ‘__main__‘】

Chaos engineering platform chaosblade box new heavy release

Digital business cloud: from planning to implementation, how does Minmetals Group quickly build a new pattern of digital development?

奔赴山海之前,毕业季一定要做的那些事情

Bao, que se passe - t - il si le serveur 100 + O & M a mal à la tête? Utilisez le majordome xingyun!

Task: denial of service DOS
随机推荐
More information about M91 fast hall measuring instrument
求各种极限的方法
[6.24-7.1] review of wonderful technical blog posts in the writing community
简版拼多多商品数据
[go ~ 0 to 1] day 4 June 30 defer, structure, method
ubuntu14安装MySQL并配置root账户本地与远程访问
Thesis reading [distinctive late semantic graph for video capturing]
Learning records of building thingsboard, an Internet of things platform
MFC中如何重绘CListCtrl的表头
案例分享:QinQ基本组网配置
实现一个Prometheus exporter
Lumiprobe cell imaging study PKH26 cell membrane labeling kit
Chinese and English instructions human soluble advanced glycation end products receptor (sRAGE) ELISA Kit
云服务器ECS夏日省钱秘籍,这次@老用户快来领走
win10下使用msys+vs2019编译ffmpeg源码
PMP是被取消了吗??
transform + asm资料
How to solve the problem of splash screen when the main and sub code streams of easygbs are h.265?
Lake Shore - crx-em-hf low temperature probe station
Solidity - 合约结构 - 错误(error)- ^0.8.4版本新增