Updated on 2024-08-05 GMT+08:00

Querying Metadata Locks

Function

Query metadata locks. Currently, this function is supported only for MySQL DB instances.

URI

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

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID.

To obtain this value, see Obtaining a Project ID.

instance_id

Yes

String

Instance ID.

Table 2 Query parameters

Parameter

Mandatory

Type

Description

db_user_id

Yes

String

Database user ID

thread_id

No

String

Session ID

database

No

String

Database name

table

No

String

Table name

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

X-Language

No

String

Language.

The value can be:

  • zh-cn
  • en-us

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

metadata_locks

Array of MetadataLock objects

List of metadata locks.

count

Integer

Number of metadata locks.

Table 5 MetadataLock

Parameter

Type

Description

thread_id

String

Session ID.

lock_status

String

Lock status. The value can be PENDING (lock wait) or GRANTED (held lock).

lock_mode

String

Metadata lock (MDL) mode. The value can be MDL_SHARED, MDL_EXCLUSIVE, MDL_SHARED_READ, or MDL_SHARED_WRITE.

lock_type

String

Lock type. The value can be Table metadata lock, Schema metadata lock, Tablespace lock, or Global read lock.

lock_duration

String

Lock scope. The value can be MDL_STATEMENT (statement-level), MDL_TRANSACTION (transaction level), or MDL_EXPLICIT (global).

table_schema

String

Database where the lock exists. This field is left blank for some global read metadata locks.

table_name

String

Table name.

user

String

User.

time

String

Time.

host

String

Host.

database

String

Database that the session belongs to.

command

String

Command.

state

String

Status.

sql

String

SQL statement.

trx_exec_time

String

Time when the transaction was executed.

block_process

Array of Process objects

List of blocked sessions.

wait_process

Array of Process objects

List of waiting sessions.

Table 6 Process

Parameter

Type

Description

id

String

Session ID.

user

String

User.

host

String

Host.

database

String

Database.

command

String

Command.

time

String

Session duration.

state

String

Status.

sql

String

SQL statement.

trx_executed_time

String

Transaction duration.

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

Minimum length: 8

Maximum length: 36

error_msg

String

Error message.

Minimum length: 2

Maximum length: 512

Status code: 500

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

Minimum length: 8

Maximum length: 36

error_msg

String

Error message.

Minimum length: 2

Maximum length: 512

Example Requests

Querying metadata locks

GET https://das.cn-north-1.myhuaweicloud.com/v3/054e292c9880d4992f02c0196d3ea468/instances/da304cd5bbb944de828759bc7be3d3fein01/metadata-locks?db_user_id=2c250598-1e3c-4d31-bc19-be1d866247e6&thread_id=12121&database=example&table=example

Example Responses

Status code: 200

{
  "metadata_locks" : [ {
    "thread_id" : "4096619",
    "lock_status" : "GRANTED",
    "lock_mode" : "MDL_SHARED_READ",
    "lock_type" : "Table metadata lock",
    "lock_duration" : "MDL_TRANSACTION",
    "table_schema" : "test_zyr",
    "table_name" : "test2",
    "user" : "root",
    "time" : "40",
    "host" : "das server",
    "database" : "test_zyr",
    "command" : "Sleep",
    "state" : "",
    "sql" : null,
    "trx_exec_time" : "341",
    "block_process" : [ ],
    "wait_process" : [ ]
  } ],
  "count" : 1
}

Status Code

Status Code

Description

200

Success.

400

Bad request.

500

Internal server error.

Error Code

For details, see Error Codes.