当前位置:网站首页>事务隔离级别 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锁。
边栏推荐
- nacos启动失败问题解决与总结
- Getting started with kubernetes command (namespaces, pods)
- ffmpeg常用命令(二)
- Supervarimag superconducting magnet system SVM series
- 正则表达式=Regex=regular expression
- Lake shore optimag superconducting magnet system om series
- Learning notes - steps of JDBC connection database operation
- Learning notes [Gumbel softmax]
- uni-app微信小程序一键登录获取权限功能
- Solidity - contract structure - error - ^0.8.4 NEW
猜你喜欢
Dom4j parsing XML, XPath retrieving XML
Parallelism, concurrency and life cycle of threads
Case sharing: basic networking configuration of QinQ
B2B e-commerce platform solution for fresh food industry to improve the standardization and transparency of enterprise transaction process
线程的并行、并发、生命周期
Methods of finding various limits
【森城市】GIS数据漫谈(一)
MySQL common graphics management tools | dark horse programmers
Digital business cloud: from planning to implementation, how does Minmetals Group quickly build a new pattern of digital development?
Solidity - contract structure - error - ^0.8.4 NEW
随机推荐
axure不显示元件库
商业智能BI开发和报表开发有什么本质区别?
241. Different Ways to Add Parentheses
indexof和includes的区别
微信小程序 navigator点击后有阴影 ,去掉navigator阴影效果
Three ways for redis to realize current limiting
XML syntax, constraints
XML语法、约束
Bao, que se passe - t - il si le serveur 100 + O & M a mal à la tête? Utilisez le majordome xingyun!
为什么一定要从DevOps走向BizDevOps?
[info() method in org.slf4j.logger]
Task: denial of service DOS
[go ~ 0 to 1] day 4 June 30 defer, structure, method
Native JS creates a calendar - supports mouse wheel scrolling to select months - and can be ported to any framework
uni-app微信小程序一键登录获取权限功能
Learning notes [Gumbel softmax]
论文阅读【Discriminative Latent Semantic Graph for Video Captioning】
Lake Shore continuous flow cryostat transmission line
奔赴山海之前,毕业季一定要做的那些事情
Boost the development of digital economy and consolidate the base of digital talents - the digital talent competition was successfully held in Kunming