共計 2313 個字符,預計需要花費 6 分鐘才能閱讀完成。
本篇文章給大家分享的是有關如何解釋 show engine innodb status 中鎖部分的內容,丸趣 TV 小編覺得挺實用的,因此分享給大家學習,希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著丸趣 TV 小編一起來看看吧。
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 中鎖部分的內容,丸趣 TV 小編相信有部分知識點可能是我們日常工作會見到或用到的。希望你能通過這篇文章學到更多知識。更多詳情敬請關注丸趣 TV 行業資訊頻道。