Updated on 2025-05-19 GMT+08:00

Querying InnoDB Lock Waits

Function

Query InnoDB lock waits. Currently, this function is supported only for MySQL DB instances.

URI

GET /v3/{project_id}/instances/{instance_id}/innodb-locks

Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Explanation:

Project ID of a tenant in a region

To obtain this value, see Obtaining a Project ID.

Constraints:

N/A

Values:

The value can contain 32 characters. Only letters and digits are allowed.

Default value:

N/A

instance_id

Yes

String

Explanation:

Unique ID of an instance

Constraints:

N/A

Values:

The value can contain 32 characters. Only letters and digits are allowed.

Default value:

N/A

Table 2 Query parameter

Parameter

Mandatory

Type

Description

db_user_id

Yes

String

Explanation:

Database user ID, that is, ID of a connection established between the database account and the database. A database user ID is created by calling the API in Registering a Database User.

Constraints:

N/A

Values:

The value is a UUID containing 36 characters. Only letters, digits, and hyphens (-) are allowed.

Default value:

N/A

Request Parameters

None

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

innodb_trx

Array of InnodbTrx objects

Explanation:

Information about the current transaction that holds or waits for a lock

Values:

N/A

innodb_lock_waits

Array of InnodbLockWaits objects

Explanation:

Mapping between the lock requested by each transaction and the lock that blocks the request

Values:

N/A

count

Integer

Explanation:

Number of transactions that currently hold or wait for locks

Values:

[0, 2^31-1]. The actual value depends on the query result.

Table 4 InnodbTrx

Parameter

Type

Description

trx_id

String

Explanation:

Transaction ID

Values:

N/A

trx_state

String

Explanation:

Transaction status

Values:

N/A

trx_started

String

Explanation:

Time when a transaction was started

Values:

N/A

trx_wait_started

String

Explanation:

Transaction ID

Values:

N/A

trx_mysql_thread_id

String

Explanation:

Session ID, same as the ID returned by the ListProcesses API

Values:

N/A

trx_query

String

Explanation:

SQL statement executed by a transaction

Values:

N/A

trx_tables_locked

String

Explanation:

Number of tables with row locks

Values:

N/A

trx_rows_locked

String

Explanation:

Number of locked rows (approximate value)

Values:

N/A

trx_rows_modified

String

Explanation:

Number of rows inserted or modified by a transaction

Values:

N/A

trx_isolation_level

String

Explanation:

Isolation level

Values:

N/A

innodb_wait_locks

Array of InnodbLock objects

Explanation:

Information about lock waits

Values:

N/A

innodb_hold_locks

Array of InnodbLock objects

Explanation:

Information about held locks

Values:

N/A

Table 5 InnodbLock

Parameter

Type

Description

lock_id

String

Explanation:

Lock ID

Values:

N/A

lock_trx_id

String

Explanation:

Transaction ID

Values:

N/A

lock_mode

String

Explanation:

Lock mode

Values:

  • S[,GAP]
  • X[,GAP]
  • IS[,GAP]
  • IX[,GAP]
  • AUTO_INC
  • UNKNOWN

lock_type

String

Explanation:

Lock type

Values:

  • RECORD: row lock
  • TABLE: table lock

lock_table

String

Explanation:

Locked table

Values:

N/A

lock_index

String

Explanation:

Index that has been locked if lock_type is RECORD. If lock_type is Table, null is returned.

Values:

N/A

lock_space

String

Explanation:

Index that has been locked if lock_type is RECORD. If lock_type is Table, null is returned.

Values:

N/A

lock_page

String

Explanation:

Page number of the locked record if lock_type is RECORD. If lock_type is Table, null is returned.

Values:

N/A

lock_rec

String

Explanation:

Heap number of the locked record if lock_type is RECORD. If lock_type is Table, null is returned.

Values:

N/A

lock_data

String

Explanation:

Primary key locked by a transaction. If lock_type is Table, null is returned.

Values:

N/A

Table 6 InnodbLockWaits

Parameter

Type

Description

requesting_trx_id

String

Explanation:

ID of a transaction that requests the lock

Values:

N/A

requested_lock_id

String

Explanation:

ID of a requested lock

Values:

N/A

blocking_trx_id

String

Explanation:

ID of a blocked transaction

Values:

N/A

blocking_lock_id

String

Explanation:

ID of a blocked lock

Values:

N/A

Example Request

Querying InnoDB lock waits

GET https://das.cn-north-1.myhuaweicloud.com/v3/054e292c9880d4992f02c0196d3ea468/instances/da304cd5bbb944de828759bc7be3d3fein01/innodb-locks?db_user_id=2c250598-1e3c-4d31-bc19-be1d866247e6

Example Responses

Status code: 200

{
  "innodb_trx" : [ {
    "trx_id" : "1080883393",
    "trx_state" : "LOCK WAIT",
    "trx_started" : "2021-01-14 18:49:26",
    "trx_wait_started" : "2021-01-14 18:49:26",
    "trx_mysql_thread_id" : "115602",
    "trx_query" : "DELETE FROM adfasdf WHERE  id =1",
    "trx_tables_locked" : "1",
    "trx_rows_locked" : "1",
    "trx_rows_modified" : "0",
    "trx_isolation_level" : "REPEATABLE READ",
    "innodb_wait_locks" : [ {
      "lock_id" : "1080883393:27750:3:2",
      "lock_trx_id" : "1080883393",
      "lock_mode" : "X",
      "lock_type" : "RECORD",
      "lock_table" : "`abc`.`adfasdf`",
      "lock_index" : "GEN_CLUST_INDEX",
      "lock_space" : "27750",
      "lock_page" : "3",
      "lock_rec" : "2",
      "lock_data" : "0x0000005528EC"
    } ],
    "innodb_hold_locks" : [ ]
  }, {
    "trx_id" : "1080882971",
    "trx_state" : "LOCK WAIT",
    "trx_started" : "2021-01-14 18:49:25",
    "trx_wait_started" : "2021-01-14 18:49:25",
    "trx_mysql_thread_id" : "115598",
    "trx_query" : "DELETE FROM adfasdf WHERE  id =1",
    "trx_tables_locked" : "1",
    "trx_rows_locked" : "1",
    "trx_rows_modified" : "0",
    "trx_isolation_level" : "REPEATABLE READ",
    "innodb_wait_locks" : [ ],
    "innodb_hold_locks" : [ {
      "lock_id" : "1080882971:27750:3:2",
      "lock_trx_id" : "1080882971",
      "lock_mode" : "X",
      "lock_type" : "RECORD",
      "lock_table" : "`abc`.`adfasdf`",
      "lock_index" : "GEN_CLUST_INDEX",
      "lock_space" : "27750",
      "lock_page" : "3",
      "lock_rec" : "2",
      "lock_data" : "0x0000005528EC"
    } ]
  } ],
  "innodb_lock_waits" : [ {
    "requesting_trx_id" : "1080883393",
    "requested_lock_id" : "1080883393:27750:3:2",
    "blocking_trx_id" : "1080882971",
    "blocking_lock_id" : "1080882971:27750:3:2"
  } ],
  "count" : 2
}

Status Code

Status Code

Description

200

Successful request

400

Bad request

500

Internal server error

Error Code

For details, see Error Codes.