当前位置:网站首页>MySQL死锁问题如何解决?背诵版
MySQL死锁问题如何解决?背诵版
2022-06-11 08:21:00 【梵高的猪v】
MySQL的死锁:
两个或两个以上的事务因为互相竞争对方的资源而导致循环等待的现象成为死锁.
如何解决死锁:
可以使用show engine innodb status语句去查看sql语句状态.然后根据对应的死锁sql找到占用的锁.
比如说: 事务A占用了a表的锁,事务B占用了b表的锁,如果此刻事务A要求占用b表的锁就得让事务b去释放b表的锁,但如果这个时候事务b也要求占用事务a的锁,就得要求事务a去释放占用a表的锁,这样子大家都循环等待,就造成了死锁.这个时候我们应该顺序让他们去占用锁,让事务ab顺序占用a锁,顺序占用b锁,这样子造成的问题无非就是哪个事务先占用锁的问题,并不会产生循环等待的情况
还比如: 在事务A执行任务的时候产生了间隙锁(-无穷,2),事务b产生了间隙锁(1,+无穷),这个时候如果事务a去执行更新3的操作,就得要求事务b去释放锁,而事务b要去执行更新0的时候就得要求事务a去释放锁.造成了互相等待的局面,这个时候就要去尝试更改逻辑删除间隙锁,或者去更改间隙锁的范围.
边栏推荐
- How to do well in empty state design? Look at this comprehensive summary
- 字符设备驱动程序之异步通知机制
- Closure and minimum dependency in database
- (completely solved) dataframe assignment settingwithcopywarning: a value is trying to be set on a copy of a slice
- Dameng database startup and shutdown
- Collation of open source modulation identification data set
- In place reversal of a LinkedList
- SSM file upload and download
- TypeScripy-类的基本使用
- Scrape captures 51job Recruitment Information (static page)
猜你喜欢

qiao-npms:获取npm包下载量

如何开始参与开源社区
![[the most complete ENSP [installation diagram] in history!]](/img/1a/7d50d6e5c06a5e3ce6acab16ddb638.jpg)
[the most complete ENSP [installation diagram] in history!]

Study the Analects of entanglement

Redis cluster in Linux system

Uniapp plug-in development

Idea annotation settings

torch. roll

(transformation) tree, binary tree and forest transformation principle

torch. nn. functional. pad
随机推荐
(completely solved) dataframe assignment settingwithcopywarning: a value is trying to be set on a copy of a slice
怎么做好项目管理?学会这4个步骤就够了
【1】 Integrated learning: quickly understand Integrated Learning
Deep understanding of add in argparse module_ Argument parameters (such as action)
What does it mean to buy a single-mode, dual-mode and Rechargeable Wireless Mouse
Interfaces and abstract classes
(resolved) the tqdm progress bar in the Jupiter notebook does not update and display in one line, but scrolls down to output
TypeScript-在koa中配置TS和使用koa-router
TypeScript-枚举
torch. roll
Summary of force deduction questions
Xshell7 and xftp7 to continue using this program, you must apply the latest updates or use a new version
Thoroughly remember the difference between ImageView background and SRC
并查集是什么?你还在为其烦恼?其实就是一个连通图的问题,理解起来没有那么困难
How to do a good job in project management? Learning these four steps is enough
Typescript class and interface, class and generic, interface merging
Use of Excel to XML tool of TestLink
The difference between equals and = =
How to find the complementary sequence of digraph
Jupyter notebook code completion plug-in + Solution