MySQL 8.0 Reference Manual Including MySQL NDB Cluster 8.0

29.12.13.1 The data_locks Table

The data_locks table shows data locks held and requested. For information about which lock requests are blocked by which held locks, see Section 29.12.13.2, “The data_lock_waits Table”.

Example data lock information:

mysql> SELECT * FROM performance_schema.data_locks\G
*************************** 1. row ***************************
               ENGINE: INNODB
       ENGINE_LOCK_ID: 139664434886512:1059:139664350547912
ENGINE_TRANSACTION_ID: 2569
            THREAD_ID: 46
             EVENT_ID: 12
        OBJECT_SCHEMA: test
          OBJECT_NAME: t1
       PARTITION_NAME: NULL
    SUBPARTITION_NAME: NULL
           INDEX_NAME: NULL
OBJECT_INSTANCE_BEGIN: 139664350547912
            LOCK_TYPE: TABLE
            LOCK_MODE: IX
          LOCK_STATUS: GRANTED
            LOCK_DATA: NULL
*************************** 2. row ***************************
               ENGINE: INNODB
       ENGINE_LOCK_ID: 139664434886512:2:4:1:139664350544872
ENGINE_TRANSACTION_ID: 2569
            THREAD_ID: 46
             EVENT_ID: 12
        OBJECT_SCHEMA: test
          OBJECT_NAME: t1
       PARTITION_NAME: NULL
    SUBPARTITION_NAME: NULL
           INDEX_NAME: GEN_CLUST_INDEX
OBJECT_INSTANCE_BEGIN: 139664350544872
            LOCK_TYPE: RECORD
            LOCK_MODE: X
          LOCK_STATUS: GRANTED
            LOCK_DATA: supremum pseudo-record

Unlike most Performance Schema data collection, there are no instruments for controlling whether data lock information is collected or system variables for controlling data lock table sizes. The Performance Schema collects information that is already available in the server, so there is no memory or CPU overhead to generate this information or need for parameters that control its collection.

Use the data_locks table to help diagnose performance problems that occur during times of heavy concurrent load. For InnoDB, see the discussion of this topic at Section 17.15.2, “InnoDB INFORMATION_SCHEMA Transaction and Locking Information”.

The data_locks table has these columns:

The data_locks table has these indexes:

TRUNCATE TABLE is not permitted for the data_locks table.

Note

Prior to MySQL 8.0.1, information similar to that in the Performance Schema data_locks table is available in the INFORMATION_SCHEMA.INNODB_LOCKS table, which provides information about each lock that an InnoDB transaction has requested but not yet acquired, and each lock held by a transaction that is blocking another transaction. INFORMATION_SCHEMA.INNODB_LOCKS is deprecated and is removed as of MySQL 8.0.1. data_locks should be used instead.

Differences between INNODB_LOCKS and data_locks:

The following table shows the mapping from INNODB_LOCKS columns to data_locks columns. Use this information to migrate applications from one table to the other.

Table 29.4 Mapping from INNODB_LOCKS to data_locks Columns

INNODB_LOCKS Column data_locks Column
LOCK_ID ENGINE_LOCK_ID
LOCK_TRX_ID ENGINE_TRANSACTION_ID
LOCK_MODE LOCK_MODE
LOCK_TYPE LOCK_TYPE
LOCK_TABLE (combined schema/table names) OBJECT_SCHEMA (schema name), OBJECT_NAME (table name)
LOCK_INDEX INDEX_NAME
LOCK_SPACE None
LOCK_PAGE None
LOCK_REC None
LOCK_DATA LOCK_DATA