当前位置:网站首页>行锁分析和死锁
行锁分析和死锁
2022-06-26 17:54:00 【 时光清浅ぴ许你安然】
一、行锁
通过检查InnoDB_row_lock状态变量来分析系统上的行锁的争夺情况:
show status like'innodb_row_lock%';
对各个状态量的说明如下:
Innodb_row_lock_current_waits: 当前正在等待锁定的数量
Innodb_row_lock_time: 从系统启动到现在锁定总时间长度
Innodb_row_lock_time_avg: 每次等待所花平均时间
Innodb_row_lock_time_max:从系统启动到现在等待最长的一次所花时间
Innodb_row_lock_waits:系统启动后到现在总共等待的次数
对于这5个状态变量,比较重要的主要是:
Innodb_row_lock_time_avg (等待平均时长)
Innodb_row_lock_waits (等待总次数)
Innodb_row_lock_time(等待总时长)
尤其是当等待次数很高,而且每次等待时长也不小的时候,我们就需要分析系统 中为什么会有如此多的等待,然后根据分析结果着手制定优化计划。
二、死锁
设置事务级为mysql默认的级别:
set tx_isolation='repeatable-read';
Session_1执行:
select * from account where id=1 for update;
Session_2执行:
select * from account where id=2 for update;
Session_1执行:
select * from account where id=2 for update;
Session_2执行:
select * from account where id=1 for update;
多数情况mysql可以自动检测死锁并回滚产生死锁的那个事务,但是有些情况 mysql没法自动检测死锁
查看近期死锁日志信息:
show engine innodb status\G;
边栏推荐
- map和filter方法对于稀缺数组的处理
- Viteconfigure project path alias
- [buuctf.reverse] 126-130
- 直播预告|程序员进击,如何提升研发效能?6月21日晚视频号、B站同步直播,不见不散!
- QPushButton 样式使用示例(以及按钮setmenu添加下拉菜单的方法)
- 背包问题求方案数
- 非对称密码体制详解
- 二分查找-2
- Leetcode HOT100 (22--- bracket generation)
- Which low code platform is more friendly to Xiaobai? Here comes the professional evaluation!
猜你喜欢
二分查找法-1
RSA encryption and decryption details
Uncover the secret of Agora lipsync Technology: driving portraits to simulate human speech through real-time voice
宝藏又小众的CTA动画素材素材网站分享
MySQL index
Vue--vuerouter cache routing component
ACL 2022 | zero sample multilingual extracted text summarization based on neural label search
MySQL add column failed because there was data before, not null by default
MySql 导出数据库中的全部表索引
The king of Internet of things protocol: mqtt
随机推荐
Discussion and generation of digital signature and analysis of its advantages
wechat_ Solve the problem of page Jump and parameter transfer by navigator in wechat applet
有依赖的背包问题
14 MySQL tutorial insert insert data
Using redis for user access data statistics hyperloglog and bitmap advanced data types
Leetcode topic [array] -268- missing numbers
[buuctf.reverse] 126-130
非对称密码体制详解
#26class中get和set设置
力扣每日一题-第28天-566.重塑矩阵
关于FlowUs这一款国民好笔记
17.13 supplementary knowledge, thread pool discussion, quantity discussion and summary
sql中ROUND和TRUNCATE的区别(四舍五入还是截取小数点后几位)
Concept and working principle of data encryption standard (DES)
Hello, is it safe to open an online stock account and buy stocks now?
二分查找法-1
VSCode使用 - Remote-SSH 配置说明
[dynamic planning] Jianzhi offer II 091 Paint the house
Please advise tonghuashun which securities firm to choose for opening an account? Is it safe to open an account online now?
Detailed explanation of browser storage methods: the origin and difference of cookies, localstorage and sessionstorage