当前位置:网站首页>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去释放锁.造成了互相等待的局面,这个时候就要去尝试更改逻辑删除间隙锁,或者去更改间隙锁的范围.
边栏推荐
- Don't want the project out of control? You need to use project management tools
- Typescript distributed condition type
- DAMENG 用户管理
- [transfer] two-way merging and sorting of C language
- Timestamp of PostgreSQL and Oracle
- Typescript class and interface, class and generic, interface merging
- JS learning basics document Write write a line of text in the page
- In an activity, view postdelay will cause memory leakage, but will not affect the life cycle execution of the activity.
- Collation of open source modulation identification data set
- Post - payload of interface test
猜你喜欢

@Usage details of postconstruct, initializingbean and initmethod

Qiao NPMS: get the download volume of NPM packages

Multiple limit of the same field of SQL

嵌入式软件面试问题总结

Bubble sorting with C language

How to find the complementary sequence of digraph

torch. meshgrid

Introduction to guava cache usage

Development of sylixos SD device driver

BFS on tree (tree breathing first search)
随机推荐
TypeScript-命名空间
CentOS essay 03:centos8.2 installing MySQL
JS learning basics document Write write a line of text in the page
qiao-lerna:lerna辅助工具
torch. meshgrid
Difference between threadpooltaskexecutor and ThreadPoolExecutor
Planning tasks for continuous automated testing
Project training - clonemon
用飞项进行目标管理,不做职场上的“无头苍蝇”
Typescript class and interface, class and generic, interface merging
uniapp 插件开发
Qiao NPMS: get the download volume of NPM packages
DAMENG 用户管理
Polymorphic interview questions
Bat batch processing separate environment packaging
The difference between & & and &
Typescript type alias
Post - payload of interface test
How to make hyperlinks in RichTextBox- How can I make a hyperlink work in a RichTextBox?
uniapp关闭/开启/调节系统声音