当前位置:网站首页>行锁分析和死锁
行锁分析和死锁
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;
边栏推荐
- Detailed contract quantification system development scheme and technical description of quantitative contract system development
- 背包问题求方案数
- 如何将应用加入到deviceidle 白名单?
- 一起备战蓝桥杯与CCF-CSP之大模拟炉石传说
- Use FST JSON to automatically generate faster JSON serialization methods
- [buuctf.reverse] 126-130
- 类型多样的石膏PBR多通道贴图素材,速来收藏!
- 14《MySQL 教程》INSERT 插入数据
- DoS及攻击方法详解
- 国信证券怎么开户?通过链接办理股票开户安全吗
猜你喜欢

玩轉Linux,輕松安裝配置MySQL

二分查找-2
![[buuctf.reverse] 126-130](/img/df/e35633d85caeff1dece62a66cb7804.png)
[buuctf.reverse] 126-130

Microservice architecture practice: user login and account switching design, order query design of the mall

数据加密标准DES安全性

The difference between round and truncate in SQL (round or truncate)

类型多样的石膏PBR多通道贴图素材,速来收藏!

Treasure and niche CTA animation material website sharing

10 cloud security best practices that enterprises need to know

Daily record 2
随机推荐
sql中ROUND和TRUNCATE的区别(四舍五入还是截取小数点后几位)
小程序设置按钮分享功能
js强制转换
请指教同花顺开户选选择哪家券商比较好?现在在线开户安全么?
KDD 2022 | 如何在跨域推荐中使用对比学习?
贝叶斯网络详解
Preparing for the Blue Bridge Cup and ccf-csp
pycharm如何修改多行注释快捷键
No manual prior is required! HKU & Tongji & lunarai & Kuangshi proposed self supervised visual representation learning based on semantic grouping, which significantly improved the tasks of target dete
清华&商汤&上海AI&CUHK提出Siamese Image Modeling,兼具linear probing和密集预测性能!
MySQL exports all table indexes in the database
我想知道,我在肇庆,到哪里开户比较好?网上开户是否安全么?
Concurrent thread safety
无需人工先验!港大&同济&LunarAI&旷视提出基于语义分组的自监督视觉表征学习,显著提升目标检测、实例分割和语义分割任务!
[uniapp] the uniapp mobile terminal uses uni Troubleshooting of navigateback failure
SIGIR 2022 | University of Hong Kong and others proposed the application of hypergraph comparative learning in Recommendation System
#25class的类继承
Detailed contract quantification system development scheme and technical description of quantitative contract system development
数字签名论述及生成与优点分析
Several key points in divorce agreement