Querying InnoDB Lock Waits
Function
Query InnoDB lock waits. Currently, this function is supported only for MySQL DB instances.
Authorization Information
Each account has permissions to call all APIs, but IAM users must have the required permissions specifically assigned.
- If you are using role/policy-based authorization, see the required permissions in Permissions Policies and Supported Actions.
- If you are using identity policy-based authorization, the following identity policy-based permissions are required.
Action
Access Level
Resource Type (*: required)
Condition Key
Alias
Dependencies
das:clouddba:listInnodbLock
List
Instance
-
-
-
URI
GET /v3/{project_id}/instances/{instance_id}/innodb-locks
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Definition Project ID of a tenant in a region To obtain this value, see Obtaining a Project ID. Constraints N/A Range The value can contain 32 characters. Only letters and digits are supported. Default Value N/A |
| instance_id | Yes | String | Definition Unique ID of an instance. You can obtain the instance ID from the instance list or instance details. Constraints N/A Range The value can contain 36 characters. Only letters and digits are allowed. Default Value N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| db_user_id | Yes | String | Definition 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 Creating a Database User. Constraints N/A Range 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
| Parameter | Type | Description |
|---|---|---|
| innodb_trx | Array of InnodbTrx objects | Definition Information about the current transaction that holds or waits for a lock |
| innodb_lock_waits | Array of InnodbLockWaits objects | Definition Mapping between the lock requested by each transaction and the lock that blocks the request |
| count | Integer | Definition Number of transactions that currently hold or wait for locks Range [0, 2^31 – 1]. The actual value depends on the query result. |
| Parameter | Type | Description |
|---|---|---|
| trx_id | String | Definition Transaction ID Range N/A |
| trx_state | String | Definition Transaction status Range
|
| trx_started | String | Definition Time when a transaction was started Range N/A |
| trx_wait_started | String | Definition Transaction ID Range N/A |
| trx_mysql_thread_id | String | Definition Session ID, same as the ID returned by the ListProcesses API Range N/A |
| trx_query | String | Definition SQL statement executed by a transaction Range N/A |
| trx_tables_locked | String | Definition Number of tables with row locks Range N/A |
| trx_rows_locked | String | Definition Number of locked rows (approximate value) Range N/A |
| trx_rows_modified | String | Definition Number of rows inserted or modified by a transaction Range N/A |
| trx_isolation_level | String | Definition Isolation level Range N/A |
| innodb_wait_locks | Array of InnodbLock objects | Definition Information about lock waits |
| innodb_hold_locks | Array of InnodbLock objects | Definition Information about held locks |
| Parameter | Type | Description |
|---|---|---|
| lock_id | String | Definition Lock ID Range N/A |
| lock_trx_id | String | Definition Transaction ID Range N/A |
| lock_mode | String | Definition Lock mode Range
|
| lock_type | String | Definition Lock type Range
|
| lock_table | String | Definition Locked table Range N/A |
| lock_index | String | Definition Index that has been locked if lock_type is RECORD. If lock_type is Table, null is returned. Range N/A |
| lock_space | String | Definition Index that has been locked if lock_type is RECORD. If lock_type is Table, null is returned. Range N/A |
| lock_page | String | Definition Page number of the locked record if lock_type is RECORD. If lock_type is Table, null is returned. Range N/A |
| lock_rec | String | Definition Heap number of the locked record if lock_type is RECORD. If lock_type is Table, null is returned. Range N/A |
| lock_data | String | Definition Primary key locked by a transaction. If lock_type is set to TABLE, null is returned. Range N/A |
| Parameter | Type | Description |
|---|---|---|
| requesting_trx_id | String | Definition ID of a transaction that requests the lock Range N/A |
| requested_lock_id | String | Definition ID of a requested lock Range N/A |
| blocking_trx_id | String | Definition ID of a blocked transaction Range N/A |
| blocking_lock_id | String | Definition ID of a blocked lock Range N/A |
Example Requests
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 Codes
| Status Code | Description |
|---|---|
| 200 | Success. |
| 400 | Bad request. |
| 500 | Internal server error. |
Error Codes
See Error Codes.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot