当前位置:网站首页>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 .
边栏推荐
- nacos启动失败问题解决与总结
- A brief understanding of white box encryption technology
- DTD建模
- 大厂音视频职位面试题目--今日头条
- 【sql优化】with as 和 临时表的区别
- 241. Different Ways to Add Parentheses
- GB28181之SIP协议
- 使用环信提供的uni-app Demo,快速实现一对一单聊
- Crunch简介、安装,使用Crunch制作密码字典
- Les canaux de culture intensive s'efforcent de développer Fu Xin et Wei Shi jiajie pour organiser une conférence de formation sur les nouveaux produits
猜你喜欢

正则表达式=Regex=regular expression

Solidity - contract structure - error - ^0.8.4 NEW

SIP protocol of gb28181

【Go ~ 0到1 】 第五天 7月1 类型别名,自定义类型,接口,包与初始化函数

Shell高级进阶

Intensive cultivation of channels for joint development Fuxin and Weishi Jiajie held a new product training conference

寶,運維100+服務器很頭疼怎麼辦?用行雲管家!

奔赴山海之前,毕业季一定要做的那些事情

Interview questions for audio and video positions in Dachang -- today's headline

Summary of SQL query de duplication statistics methods
随机推荐
Ffmpeg audio related commands
【sql优化】with as 和 临时表的区别
Ffmpeg avframe to cv:: mat
PostgreSQL varchar[] array type operation
智慧防疫系统为建筑工地复工复产提供安全保障
optaplanner学习笔记(一)案例Cloud balance
Dom4J解析XML、Xpath检索XML
Introduction and installation of crunch, and making password dictionary with crunch
【Go ~ 0到1 】 第四天 6月30 defer,结构体,方法
241. Different Ways to Add Parentheses
学习笔记-JDBC连接数据库操作的步骤
ffmpeg常用命令(二)
Boost the development of digital economy and consolidate the base of digital talents - the digital talent competition was successfully held in Kunming
Ubuntu14 install MySQL and configure root account local and remote access
简版拼多多商品数据
XML语法、约束
Les canaux de culture intensive s'efforcent de développer Fu Xin et Wei Shi jiajie pour organiser une conférence de formation sur les nouveaux produits
正则表达式=Regex=regular expression
白盒加密技术浅理解
Shell高级进阶