当前位置:网站首页>事务隔离级别 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锁。
边栏推荐
- axure不显示元件库
- Dom4J解析XML、Xpath检索XML
- Case sharing: basic networking configuration of QinQ
- CMU AI PhD 第一年总结
- B2B e-commerce platform solution for fresh food industry to improve the standardization and transparency of enterprise transaction process
- uni-app商品分类
- PMP是被取消了吗??
- indexof和includes的区别
- 241. Different Ways to Add Parentheses
- Native JS creates a calendar - supports mouse wheel scrolling to select months - and can be ported to any framework
猜你喜欢

Shell高级进阶

XML syntax, constraints

How to solve the problem of splash screen when the main and sub code streams of easygbs are h.265?

Solidity - 算术运算的截断模式(unchecked)与检查模式(checked)- 0.8.0新特性

Native JS creates a calendar - supports mouse wheel scrolling to select months - and can be ported to any framework

为什么一定要从DevOps走向BizDevOps?

Solution and summary of Nacos startup failure

Cdga | if you are engaged in the communication industry, you should get a data management certificate

【森城市】GIS数据漫谈(一)

pickle.load报错【AttributeError: Can‘t get attribute ‘Vocabulary‘ on <module ‘__main__‘】
随机推荐
Learning notes - steps of JDBC connection database operation
pickle. Load error [attributeerror: can't get attribute 'volatile' on < module '\u main']
从零开始学 MySQL —数据库和数据表操作
【6.24-7.1】写作社区精彩技术博文回顾
【To .NET】C#集合类源码解析
原生js打造日程表-支持鼠标滚轮滚动选择月份-可以移植到任何框架中
OpenCV视频质量检测--清晰度检测
Solution of digital supply chain centralized purchase platform in mechanical equipment industry: optimize resource allocation and realize cost reduction and efficiency increase
正则表达式=Regex=regular expression
Witness the times! "The future of Renji collaboration has come" 2022 Hongji ecological partnership conference opens live broadcast reservation
Lake Shore低温恒温器的氦气传输线
记一次 .NET 差旅管理后台 CPU 爆高分析
More information about M91 fast hall measuring instrument
Lumiprobe phosphide hexaethylene phosphide specification
【Go ~ 0到1 】 第五天 7月1 类型别名,自定义类型,接口,包与初始化函数
赋能「新型中国企业」,SAP Process Automation 落地中国
Dom4j parsing XML, XPath retrieving XML
Lake Shore continuous flow cryostat transmission line
研究了11种实时聊天软件,我发现都具备这些功能…
Solidity - contract structure - error - ^0.8.4 NEW