当前位置:网站首页>Row lock analysis and deadlock
Row lock analysis and deadlock
2022-06-26 17:56:00 【Time is light, you are safe】
One 、 Row lock
clear through InnoDB_row_lock State variables are used to analyze the contention of row locks on the system :
show status like'innodb_row_lock%';
The description of each state quantity is as follows :
Innodb_row_lock_current_waits: The number of currently waiting locks
Innodb_row_lock_time: The total length of time from system startup to lock up
Innodb_row_lock_time_avg: The average time it takes to wait
Innodb_row_lock_time_max: The longest waiting time from system startup to now
Innodb_row_lock_waits: The total number of times the system has been waiting since it was started
For this 5 Two state variables , The more important thing is :
Innodb_row_lock_time_avg ( Average waiting time )
Innodb_row_lock_waits ( Total waiting times )
Innodb_row_lock_time( The total waiting time )
Especially when waiting times are high , And every time the waiting time is not small , We need an analysis system Why is there so much waiting in , Then according to the results of the analysis to develop optimization plan .
Two 、 Deadlock
Set transaction level to mysql Default level :
set tx_isolation='repeatable-read';
Session_1 perform :
select * from account where id=1 for update;
Session_2 perform :
select * from account where id=2 for update;
Session_1 perform :
select * from account where id=2 for update;
Session_2 perform :
select * from account where id=1 for update;
In most cases mysql Deadlock can be detected automatically and the transaction that generated the deadlock can be rolled back , But in some cases mysql Can't automatically detect deadlocks
Check the recent deadlock log information :
show engine innodb status\G;
边栏推荐
- 并发之Synchronized说明
- 解决pycharm里面每个字母占一格空格的问题
- 力扣每日一题-第28天-566.重塑矩阵
- 手写promise.all
- #26class中get和set设置
- Bayesian network explanation
- Chen Qiang: Alibaba's 100 billion level large-scale digital business knowledge map helps business growth
- RSA概念详解及工具推荐大全 - lmn
- Problems encountered this week
- [ten thousand words summary] starting from the end, analyze in detail how to fill in the college entrance examination volunteers
猜你喜欢
Strength and appearance Coexist -- an exclusive interview with Liu Yu, a member of Apache pulsar PMC
【代码随想录-动态规划】T583、两个字符串的删除操作
Lm06 the mystery of constructing the bottom and top trading strategy only by trading volume
Data Encryption Standard DES security
[buuctf.reverse] 126-130
数据加密标准DES安全性
idea中文插件chinese(simplified) language pack
MySQL exports all table indexes in the database
并发之Synchronized说明
接水面试题
随机推荐
[dynamic planning] Jianzhi offer II 091 Paint the house
wechat_ Solve the problem of page Jump and parameter transfer by navigator in wechat applet
Leetcode daily [2022 - 02 - 16]
【NPOI】C#跨工作薄复制Sheet模板导出Excel
贝叶斯网络详解
How about opening an account at Guojin securities? Is it safe?
[recommendation system learning] recommendation system architecture
Redis and database data consistency
[QNX] Command
行锁与隔离级别案例分析
并发之Synchronized说明
背包问题求方案数
MySQL add column failed because there was data before, not null by default
Knapsack problem with dependency
KDD 2022 | 如何在跨域推荐中使用对比学习?
How pycharm modifies multiline annotation shortcuts
transforms.RandomCrop()的输入只能是PIL image 不能是tensor
丰富专业化产品线, 江铃福特领睿·极境版上市
Problems encountered this week
Synchronized description of concurrency