# Blocked SQL

+ `DATA_LOCK_WAITS` 
  + Locks such as pessimistic locks that are currently occurring on all TiKV nodes in the cluster
  + Only users with PROCESS privilege can query
  + Get real-time access from all TiKV nodes
  + If the cluster is large and the load is high, querying the table poses a potential risk of performance jitter
+ `DEADLOCKS` 
  + Provides information on several recent deadlock errors that have occurred on the current TiDB node
  + Holds information for the last 10 deadlock errors by default
+ `TIDB_TRX` 
  + return information on transaction being executed on all TiDB
  + Only users with PROCESS privilege can query
------------------------------------------------------------

Locked view was officially introduced in TiDB v5.2.0 version, which greatly simplifies the troubleshooting difficulty of users in TiDB things blocking time
The lock view mainly involves three system tables:
- The DATA_LOCK_WAITS table shows pessimistic locks and other locks currently occurring on all TiKV nodes in the cluster
  - Only users with the PROCESS privilege can query this table.
  - The information in the DATA_LOCK_WAITS table is obtained in real time from all TiKV nodes at the time of query.
  - If the cluster is large and the load is high, querying the table has the potential risk of causing performance jitter; evaluate the actual usage
- The DEADLOCKS table provides information on several recent deadlock errors that have occurred on the current TiDB node
  - CLUSTER_DEADLOCKS table return information on the number of recent deadlock errors that occurred in each TiDB node on the entire cluster
  - Holds information for the last 10 deadlock errors by default
  - Can be adjusted via the pessimistic-txn.deadlock-history-capacity configuration item in the TiDB configuration file
- The TIDB_TRX table provides information on transaction currently being executed on the TiDB node
  - The query result of the CLUSTER_TIDB_TRX table contains an additional INSTANCE column, which return information on transaction being executed on all TiDBs
  - Only users with PROCESS privilege can get the full information in this table
