温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何解释show engine innodb status中锁部分的内容

发布时间:2021-11-16 11:37:22 来源:亿速云 阅读:241 作者:柒染 栏目:MySQL数据库

本篇文章给大家分享的是有关如何解释show engine innodb status中锁部分的内容,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。

 LOCK WAIT 2 lock struct(s), heap size 1136, 1 row lock(s)
MySQL thread id 4, OS thread handle 140665176164096, query id 575 localhost root update
insert into testpri values(13,10)
------- TRX HAS BEEN WAITING 9 SEC FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 723 page no 3 n bits 80 index PRIMARY of table `test`.`testpri` trx id 6953526 lock_mode X locks gap before rec insert intention waiting
Record lock, heap no 5 PHYSICAL RECORD: n_fields 4; compact format; info bits 0
 0: len 4; hex 8000000f; asc     ;;
 1: len 6; hex 0000006a1a29; asc    j );;
 2: len 7; hex ba000040370110; asc    @7  ;;
 3: len 4; hex 80000014; asc     ;;
 

如上: 
 lock struct 内存结构 一个事物可以包含多个锁结构 包含表锁和行锁结构 对应lock_rec_t和lock_table_t结构体, LOCK WAIT 为锁的一种状态
为此我修改了源代码关于锁打印部分如下能够看到各个锁结构体的类容:
---TRANSACTION 173210, ACTIVE 8 sec
2 lock struct(s), heap size 1160, 1 row lock(s)
MySQL thread id 2, OS thread handle 140737154311936, query id 174 localhost root cleaning up
---lock strcut(1):(Add by gaopeng) In modify Version I force check all REC_LOCK/TAB_LOCK chain! for this Trx
TABLE LOCK table `test`.`testmmm` trx id 173210 lock mode IX
---lock strcut(2):(Add by gaopeng) In modify Version I force check all REC_LOCK/TAB_LOCK chain! for this Trx
RECORD LOCKS space id 253 page no 3 n bits 80 index PRIMARY of table `test`.`testmmm` trx id 173210 lock_mode X locks rec but not gap
Record lock, heap no 9 PHYSICAL RECORD: n_fields 4; compact format; info bits 0
 0: len 4; hex 80000023; asc    #;;
 1: len 6; hex 0000000298ee; asc       ;;
 2: len 7; hex d90000023d0110; asc     =  ;;
 3: len 7; hex 67616f70656e67; asc gaopeng;;

 heap size 这些内存结构体占用的堆内存大小
 1 row lock(s) 行锁结构锁定一行数据,一个lock_rec_t包含了page no同时 包含了行数+64 位的一个位图,每一位对应
               page中heap no的位置。
 RECORD LOCKS space id 723 page no 3:就是tablespace id和page 号
 n bits 80:和这个page相关的锁位图的大小我的表为9条数据 还包含2个起始和结束虚拟列 及 64+11 bits,及75bits但是必须被8整除为一个字节就是80 bits
 heap no 5:此行在page中的heap no heap no存储在fixed_extrasize 中,heap no 为物理存储填充的序号,页的空闲空间挂载在page free链表中(头插法)可以重用,但是重用此heap no不变,
            如果一直是insert 则heap no 不断增加,并非按照KEY大小排序的逻辑链表顺序,而是物理填充顺序 
            
 0: len 4; hex 8000000f; asc     ;; 聚合索引实际KEY 0XF 15   8位最高位为符号位1为正数
 1: len 6; hex 0000006a1a29; asc    j );;transaction id 虚拟行
 2: len 7; hex ba000040370110; asc    @7  ;;roll pointer 虚拟行
 3: len 4; hex 80000014; asc     ;; 行中其他数据 这里只有一个 0x14 20 

以上就是如何解释show engine innodb status中锁部分的内容,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI