MySQL information_schema庫中關於三個關於鎖相關表的欄位解釋彙總

chenfeng發表於2017-07-20
innodb_trx表:
trx_id:事務ID。
trx_state:事務狀態,有以下幾種狀態:RUNNING、LOCK WAIT、ROLLING BACK 和 COMMITTING。
trx_started:事務開始時間。
trx_requested_lock_id:事務當前正在等待鎖的標識,可以和 INNODB_LOCKS 表 JOIN 以得到更多詳細資訊。
trx_wait_started:事務開始等待的時間。
trx_weight:事務的權重。
trx_mysql_thread_id:事務執行緒 ID,可以和 PROCESSLIST 表 JOIN。
trx_query:事務正在執行的 SQL 語句。
trx_operation_state:事務當前操作狀態。
trx_tables_in_use:當前事務執行的 SQL 中使用的表的個數。
trx_tables_locked:當前執行 SQL 的行鎖數量。
trx_lock_structs:事務保留的鎖數量。
trx_lock_memory_bytes:事務鎖住的記憶體大小,單位為 BYTES。
trx_rows_locked:事務鎖住的記錄數。包含標記為 DELETED,並且已經儲存到磁碟但對事務不可見的行。
trx_rows_modified:事務更改的行數。
trx_concurrency_tickets:事務併發票數。
trx_isolation_level:當前事務的隔離級別。
trx_unique_checks:是否開啟唯一性檢查的標識。
trx_foreign_key_checks:是否開啟外來鍵檢查的標識。
trx_last_foreign_key_error:最後一次的外來鍵錯誤資訊。
trx_adaptive_hash_latched:自適應雜湊索引是否被當前事務鎖住的標識。
trx_adaptive_hash_timeout:是否立刻放棄為自適應雜湊索引搜尋 LATCH 的標識。

innodb_locks表:
lock_id:鎖 ID。
lock_trx_id:擁有鎖的事務 ID。可以和 INNODB_TRX 表 JOIN 得到事務的詳細資訊。
lock_mode:鎖的模式。有如下鎖型別:行級鎖包括:S、X、IS、IX,分別代表:共享鎖、排它鎖、意向共享鎖、意向排它鎖。表級鎖包括:S_GAP、X_GAP、IS_GAP、IX_GAP 和 AUTO_INC,分別代表共享間隙鎖、排它間隙鎖、意向共享間隙鎖、意向排它間隙鎖和自動遞增鎖。
lock_type:鎖的型別。RECORD 代表行級鎖,TABLE 代表表級鎖。
lock_table:被鎖定的或者包含鎖定記錄的表的名稱。
lock_index:當 LOCK_TYPE=’RECORD’ 時,表示索引的名稱;否則為 NULL。
lock_space:當 LOCK_TYPE=’RECORD’ 時,表示鎖定行的表空間 ID;否則為 NULL。
lock_page:當 LOCK_TYPE=’RECORD’ 時,表示鎖定行的頁號;否則為 NULL。
lock_rec:當 LOCK_TYPE=’RECORD’ 時,表示一堆頁面中鎖定行的數量,亦即被鎖定的記錄號;否則為 NULL。
lock_data:當 LOCK_TYPE=’RECORD’ 時,表示鎖定行的主鍵;否則為NULL。

innodb_lock_waits表:
requesting_trx_id:請求事務的 ID。
requested_lock_id:事務所等待的鎖定的 ID。可以和 INNODB_LOCKS 表 JOIN。
blocking_trx_id:阻塞事務的 ID。
blocking_lock_id:某一事務的鎖的 ID,該事務阻塞了另一事務的執行。可以和 INNODB_LOCKS 表 JOIN。


innodb_trx表查詢結果舉例:
mysql(mdba@localhost:(none) 03:48:05)>select * from information_schema.innodb_trx \G
*************************** 1. row ***************************
                    trx_id: 3404472915
                 trx_state: RUNNING
               trx_started: 2017-07-20 15:48:14
     trx_requested_lock_id: NULL
          trx_wait_started: NULL
                trx_weight: 3
       trx_mysql_thread_id: 27044647
                 trx_query: commit
       trx_operation_state: committing
         trx_tables_in_use: 0
         trx_tables_locked: 1
          trx_lock_structs: 2
     trx_lock_memory_bytes: 1136
           trx_rows_locked: 1
         trx_rows_modified: 1
   trx_concurrency_tickets: 0
       trx_isolation_level: REPEATABLE READ
         trx_unique_checks: 1
    trx_foreign_key_checks: 1
trx_last_foreign_key_error: NULL
 trx_adaptive_hash_latched: 0
 trx_adaptive_hash_timeout: 0
          trx_is_read_only: 0
trx_autocommit_non_locking: 0
*************************** 2. row ***************************
                    trx_id: 3404264783
                 trx_state: RUNNING
               trx_started: 2017-07-20 15:42:06
     trx_requested_lock_id: NULL
          trx_wait_started: NULL
                trx_weight: 2
       trx_mysql_thread_id: 22514654
                 trx_query: update qymc set status1='2' where id=962304
       trx_operation_state: NULL
         trx_tables_in_use: 0
         trx_tables_locked: 1
          trx_lock_structs: 1
     trx_lock_memory_bytes: 1136
           trx_rows_locked: 0
         trx_rows_modified: 1
   trx_concurrency_tickets: 0
       trx_isolation_level: REPEATABLE READ
         trx_unique_checks: 1
    trx_foreign_key_checks: 1
trx_last_foreign_key_error: NULL
 trx_adaptive_hash_latched: 0
 trx_adaptive_hash_timeout: 0
          trx_is_read_only: 0
trx_autocommit_non_locking: 0
....................................................................................
....................................................................................
....................................................................................
....................................................................................


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15498/viewspace-2142352/,如需轉載,請註明出處,否則將追究法律責任。

相關文章