当前位置:网站首页>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 .
边栏推荐
- Methods of finding various limits
- [English grammar] Unit1 articles, nouns, pronouns and numerals
- MySQl的基本使用
- Detailed explanation of JUnit unit test framework
- Instagram 为何从内容共享平台变成营销工具?独立站卖家如何利用该工具?
- IPv4地址、子网掩码、网关
- 商业智能BI开发和报表开发有什么本质区别?
- Audio and video, encoding and decoding related e-books, gadgets, packaged for free!
- ffmpeg AVFrame 转 cv::Mat
- Live HLS protocol
猜你喜欢

赋能「新型中国企业」,SAP Process Automation 落地中国

混沌工程平台 ChaosBlade-Box 新版重磅发布

求各种极限的方法

SIP protocol of gb28181

Audio and video, encoding and decoding related e-books, gadgets, packaged for free!

精耕渠道共謀發展 福昕攜手偉仕佳傑開展新產品培訓大會

正则表达式=Regex=regular expression

DTD modeling

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

Bao, que se passe - t - il si le serveur 100 + O & M a mal à la tête? Utilisez le majordome xingyun!
随机推荐
DTD建模
使用环信提供的uni-app Demo,快速实现一对一单聊
物联网平台thingsboard搭建学习记录
【6.24-7.1】写作社区精彩技术博文回顾
Bao, what if the O & M 100+ server is a headache? Use Xingyun housekeeper!
记一次 .NET 差旅管理后台 CPU 爆高分析
Introduction and installation of crunch, and making password dictionary with crunch
[go ~ 0 to 1] day 4 June 30 defer, structure, method
uni-app微信小程序一键登录获取权限功能
pickle.load报错【AttributeError: Can‘t get attribute ‘Vocabulary‘ on <module ‘__main__‘】
118. 杨辉三角
XML语法、约束
大厂音视频职位面试题目--今日头条
【org.slf4j.Logger中info()方法】
Bao, que se passe - t - il si le serveur 100 + O & M a mal à la tête? Utilisez le majordome xingyun!
Instagram 为何从内容共享平台变成营销工具?独立站卖家如何利用该工具?
Live HLS protocol
H264编码profile & level控制
求各种极限的方法
brpc理解