当前位置:网站首页>行锁分析和死锁
行锁分析和死锁
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;
边栏推荐
- 在国金证券开户怎么样?保障安全吗?
- LeetCode——226. Flip binary tree (BFS)
- Prometeus 2.34.0 new features
- sql中ROUND和TRUNCATE的区别(四舍五入还是截取小数点后几位)
- Distributed Architecture Overview
- ZCMU--1367: Data Structure
- 【Unity】在Unity中使用C#执行外部文件,如.exe或者.bat
- vue--vuerouter缓存路由组件
- SIGIR 2022 | University of Hong Kong and others proposed the application of hypergraph comparative learning in Recommendation System
- Detailed explanation of browser storage methods: the origin and difference of cookies, localstorage and sessionstorage
猜你喜欢

Leetcode - 226. Retourner l'arbre binaire (bfs)

LM06丨仅用成交量构造抄底摸顶策略的奥秘

VSCode使用 - Remote-SSH 配置说明

MySql 导出数据库中的全部表索引

Ndroid development from introduction to mastery Chapter 2: view and ViewGroup
![[ten thousand words summary] starting from the end, analyze in detail how to fill in the college entrance examination volunteers](/img/77/715454c8203d722e246ed70e1fe0d8.png)
[ten thousand words summary] starting from the end, analyze in detail how to fill in the college entrance examination volunteers
![[buuctf.reverse] 126-130](/img/df/e35633d85caeff1dece62a66cb7804.png)
[buuctf.reverse] 126-130

halcon之区域:多种区域(Region)特征(5)

sparksql如何通过日期返回具体周几-dayofweek函数

Army chat -- registration of Registration Center
随机推荐
有依赖的背包问题
牛客网:设计LRU缓存结构 设计LFU缓存结构
【uniapp】uniapp手机端使用uni.navigateBack失效问题解决
Detailed explanation of dos and attack methods
分布式缓存/缓存集群简介
Preparing for the Blue Bridge Cup and ccf-csp
[code Capriccio - dynamic planning] t583. Deleting two strings
【动态规划】剑指 Offer II 091. 粉刷房子
MySQL exports all table indexes in the database
Concept and working principle of data encryption standard (DES)
Redis and database data consistency
Live broadcast preview | how can programmers improve R & D efficiency? On the evening of June 21, the video number and station B will broadcast live at the same time. See you or leave!
Prometeus 2.34.0 新特性
关于FlowUs这一款国民好笔记
Concurrent thread safety
Jouer avec Linux et installer et configurer MySQL facilement
[recommendation system learning] technology stack of recommendation system
【QNX】命令
Leetcode topic [array] -268- missing numbers
手写promise.all