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
作者微信:
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
作者微信: