当前位置:网站首页>事务隔离级别 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锁。
边栏推荐
- Helium transmission line of lake shore cryostat
- GB28181之SIP协议
- 【pytorch记录】自动混合精度训练 torch.cuda.amp
- AAAI2020: Real-time Scene Text Detection with Differentiable Binarization
- 【森城市】GIS数据漫谈(一)
- How to redraw the header of CListCtrl in MFC
- Flutter 实战-快速实现音视频通话应用
- ubuntu14安装MySQL并配置root账户本地与远程访问
- Learning notes [Gumbel softmax]
- indexof和includes的区别
猜你喜欢

研究了11种实时聊天软件,我发现都具备这些功能…

What must be done in graduation season before going to Shanhai

宝,运维100+服务器很头疼怎么办?用行云管家!

ECS summer money saving secret, this time @ old users come and take it away

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

Facebook聊单,SaleSmartly有妙招!

nacos配置文件发布失败,请检查参数是否正确的解决方案

Instagram 为何从内容共享平台变成营销工具?独立站卖家如何利用该工具?

Junit单元测试框架详解

Solidity - 算术运算的截断模式(unchecked)与检查模式(checked)- 0.8.0新特性
随机推荐
正则表达式=Regex=regular expression
Manufacturing SRM management system supplier all-round closed-loop management, to achieve procurement sourcing and process efficient collaboration
Lake Shore - crx-em-hf low temperature probe station
Dlib+opencv library for fatigue detection
精耕渠道共谋发展 福昕携手伟仕佳杰开展新产品培训大会
商业智能BI开发和报表开发有什么本质区别?
Solidity - 合约结构 - 错误(error)- ^0.8.4版本新增
GB28181的NAT穿透
【Go ~ 0到1 】 第五天 7月1 类型别名,自定义类型,接口,包与初始化函数
ubuntu14安装MySQL并配置root账户本地与远程访问
EasyGBS主子码流都为H.265时,切换出现花屏如何解决?
Bao, que se passe - t - il si le serveur 100 + O & M a mal à la tête? Utilisez le majordome xingyun!
MATLAB中subplot函数的使用
Methods of finding various limits
精耕渠道共謀發展 福昕攜手偉仕佳傑開展新產品培訓大會
Shell高级进阶
Solution of digital supply chain centralized purchase platform in mechanical equipment industry: optimize resource allocation and realize cost reduction and efficiency increase
研究了11种实时聊天软件,我发现都具备这些功能…
Dom4j parsing XML, XPath retrieving XML
nacos配置文件发布失败,请检查参数是否正确的解决方案