tencent cloud

TDSQL Boundless

METADATA_LOCKS

PDF
Modo Foco
Tamanho da Fonte
Última atualização: 2026-02-10 11:06:28

Feature

METADATA_LOCKS records the current usage of metadata locks of SQLEngine, including:
Granted locks: Display which sessions currently possess which metadata locks.
Locks requested but not yet granted: Display which sessions are waiting for which metadata locks.
Lock requests terminated by the deadlock detector.
Lock requests that have timed out and are waiting for the request session to release the lock.
The feature is to help users quickly locate issues related to metadata locks (MDL) and improve system stability and performance.

Field Description

Field Name
Type
Description
OBJECT_TYPE
varchar(64)
Indicates the types of locked objects, such as TABLE, SCHEMA, FUNCTION, and MC.
Among them, MC is a lock for global objects newly introduced by TDSQL Boundless, which locks database objects at the cluster level.
OBJECT_SCHEMA
varchar(64)
Indicates the name of the database where the locked object is located.
OBJECT_NAME
varchar(64)
Indicates the name of the locked object.
COLUMN_NAME
varchar(64)
Indicates the name of the specific column of the locked object.
OBJECT_INSTANCE_BEGIN
bigint unsigned
Indicates the address of the locked object in memory.
LOCK_TYPE
varchar(32)
Indicates the types of locks.
INTENTION_EXCLUSIVE: Intention exclusive lock. This type of lock is usually used to indicate that a transaction intends to obtain an exclusive lock but has not yet actually obtained it.
SHARED: Shared lock. This type of lock allows multiple transactions to hold it but prevents any transaction from obtaining an exclusive lock.
SHARED_HIGH_PRIO: High-priority shared lock. This is a special type of shared lock used for high-priority transactions.
SHARED_READ: Shared read lock. It allows transactions to read data but prevents them from writing data or obtaining an exclusive lock.
SHARED_UPGRADABLE: Upgradeable shared lock. This type of lock allows a transaction to attempt to obtain an exclusive lock while holding a shared lock without being blocked.
SHARED_NO_WRITE: Shared lock that does not allow writing. This type of lock may prevent transactions from writing data but allows reading.
SHARED_NO_READ_WRITE: Shared lock that does not allow reading or writing. This type of lock prevents transactions from reading and writing data.
EXCLUSIVE: Exclusive lock. This type of lock allows only one transaction to hold it and prevents other transactions from obtaining any type of lock.
LOCK_DURATION
varchar(32)
Indicates the lock duration, such as TRANSACTION and LONG.
LOCK_STATUS
varchar(32)
Indicates the status of each lock:
PENDING: When a metadata lock is requested but not immediately obtained, insert a record with a status of PENDING.
GRANTED: When a metadata lock is requested and immediately obtained, insert a record with a status of GRANTED.
VICTIM: When the deadlock detector cancels a suspended lock request to break a deadlock (ER_LOCK_DEADLOCK), its row status is updated from PENDING to VICTIM. This indicates that the lock row is about to be deleted.
TIMEOUT: When a suspended lock request times out (ER_LOCK_WAIT_TIMEOUT), its row status is updated from PENDING to TIMEOUT. This indicates that the lock row is about to be deleted.
KILLED: When a granted lock or a lock request that is suspended is terminated, its row status is updated from GRANTED or PENDING to KILLED. This indicates that the lock row is about to be deleted.
SOURCE
varchar(64)
Indicates the name of the source file containing the detected code that generated the event and the line number in the file where the detection occurred.
OWNER_THREAD_ID
bigint unsigned
Indicates the ID of the thread holding the lock.
OWNER_EVENT_ID
bigint unsigned
Indicates the event ID of the metadata lock request.

Examples

#session1
BEGIN
UPDATE test1 SET k = 0 WHERE id = 999;

#session2
ALTER TABLE test1 ADD COLUMN new_column VARCHAR(255);

#By viewing metadata_locks, you can see that the DDL's attempt to obtain the metadata lock is suspended.
tdsql [performance_schema]> select * from metadata_locks where OBJECT_NAME='test1' \\G
*************************** 1. row ***************************
OBJECT_TYPE: TABLE
OBJECT_SCHEMA: etest
OBJECT_NAME: test1
COLUMN_NAME: NULL
OBJECT_INSTANCE_BEGIN: 140400821752448
LOCK_TYPE: EXCLUSIVE
LOCK_DURATION: TRANSACTION
LOCK_STATUS: PENDING
SOURCE: mdl.cc:3924
OWNER_THREAD_ID: 5670
OWNER_EVENT_ID: 1
1 row in set (0.00 sec)

Ajuda e Suporte

Esta página foi útil?

comentários