当前位置:网站首页>Transaction isolation level gap lock deadlock
Transaction isolation level gap lock deadlock
2022-07-01 19:36:00 【Like this, I】
1. Transaction isolation level
- serialize (SERIALIZABLE)
- Repeatable (REPEATABLE READ)
- Submit to read (READ COMMITTED)
- Uncommitted read (READ UNCOMMITTED)
The four isolation levels correspond to addition, deletion, modification and query
2.gap Lock analysis :
Uncommitted read (READ UNCOMMITTED): Add, delete, change and check without locking .
Submit to read (READ COMMITTED): Increase the time to lock the index a certain distance ( If the index is 12, Lock an index in 12 A distance up and down ), Release the lock when the transaction is committed .
Repeatable (REPEATABLE READ): Lock the index for a distance when adding, deleting or modifying data (insert Above , If the index is 12, Then lock the distance between the indexes of the previous row and the next row , If there is no previous line or next line , Then lock a distance )
serialize (SERIALIZABLE): Add, delete, change and check will be locked , Transactions can only be committed one by one , The obtained transaction locks the table directly
3.gap Deadlock
Two transaction colleagues obtained an interval lock , And simultaneously operate the interval
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');
This is the time , You may get an error message ERROR 1213 (40001): Deadlock found when trying toget lock; try restarting transaction.
The reason is that the first two statements have been obtained [2,20) Recorded in this interval S lock , Then, the two transactions are performed on col_id=10 This location request X lock , Then a deadlock occurs , No one can ask X lock , Because they both hold S lock .
边栏推荐
- Go Language Advanced
- 记一次 .NET 差旅管理后台 CPU 爆高分析
- 简版拼多多商品数据
- 微信公众号开发相关流程及功能介绍
- Use the uni app demo provided by Huanxin to quickly realize one-on-one chat
- ffmpeg 错误码
- Facebook聊单,SaleSmartly有妙招!
- ECS summer money saving secret, this time @ old users come and take it away
- 论文阅读【Discriminative Latent Semantic Graph for Video Captioning】
- A brief understanding of white box encryption technology
猜你喜欢
随机推荐
Ffmpeg error code
ubuntu14安装MySQL并配置root账户本地与远程访问
ES6中的代理proxy
Ubuntu14 install MySQL and configure root account local and remote access
使用环信提供的uni-app Demo,快速实现一对一单聊
brpc理解
Lean thinking: source, pillar, landing. I understand it after reading this article
Case sharing: basic networking configuration of QinQ
【To .NET】C#集合类源码解析
win10下使用msys+vs2019编译ffmpeg源码
精耕渠道共谋发展 福昕携手伟仕佳杰开展新产品培训大会
The intelligent epidemic prevention system provides safety guarantee for the resumption of work and production at the construction site
Introduction and installation of crunch, and making password dictionary with crunch
Learning notes - steps of JDBC connection database operation
Facebook聊单,SaleSmartly有妙招!
Task: denial of service DOS
GB28181的NAT穿透
奔赴山海之前,毕业季一定要做的那些事情
axure不显示元件库
Write it down once Net travel management background CPU Explosion Analysis