Add Lock View documents#5798
Conversation
|
|
||
| The meaning of each column field in the `DATA_LOCK_WAITS` table is as follows: | ||
|
|
||
| * `KEY`: The KEY that is waiting for the lock and displayed in the form of hexadecimal code. |
There was a problem hiding this comment.
In the context of displaying a long byte array, maybe calling it "hexadecimal string" looks better than "hexadecimal code"?
| > **Warning:** | ||
| > | ||
| > * The information in this table is obtained in real time from all TiKV nodes during the query. Currently, even if the `WHERE` condition is added, TiDB might still collect information from all TiKV nodes. If the cluster is large and the load is high, querying this table might cause a potential risk of performance jitter. Therefore, use this table according to your actual situation. | ||
| > * The information from different TiKV nodes is not necessarily the snapshot at the same point in time. |
There was a problem hiding this comment.
Comparing to the word "necessarily", I think maybe "guaranteed" or "promised" looks more clear?
| 2 rows in set (0.01 sec) | ||
| ``` | ||
|
|
||
| The above query result shows that the transaction of the ID `425405024158875649` was trying to obtain the pessimistic lock on the key `7480000000000000355f728000000000000002` when the statement with digest `"f7530877a35ae65300c42250abd8bc731bbaf0a7cabc05dab843565230611bb22"` was being executed, but this key was held by the transaction of the ID `425405016242126849`. |
There was a problem hiding this comment.
but this key was held by the transaction of the ID
425405016242126849
It's not "the key" that's being held, but "the lock on the key". I just noticed that the Chinese version of this sentence has the same mistake 😥
|
|
||
| The `DATA_LOCK_WAITS` table records the SQL digest but not the original SQL statement. | ||
|
|
||
| SQL digest is the hash value after the SQL normalization. To find the original SQL statement corresponding to the SQL digest, perform one of the following operations: |
There was a problem hiding this comment.
SQL digest is the hash value after the SQL normalization
How about "SQL digest is the hash value of the normalized SQL statement"?
| * `DEADLOCK_ID`: The ID of the deadlock event. When multiple deadlock errors exist in the table, you can use this column to distinguish rows that belong to different deadlock errors. | ||
| * `OCCUR_TIME`: The time when the deadlock error occurs. | ||
| * `RETRYABLE`: Whether the deadlock error can be retried. Currently, TiDB does not support collecting the information of the retryable deadlock error, so the value of this field is always `0`. For the description of retryable deadlock errors, see the [Retryable deadlock errors](#retryable-deadlock-errors) section. | ||
| * `TRY_LOCK_TRX_ID`: The ID of the transaction that tries to add lock, which is the `start_ts` of the transaction. |
There was a problem hiding this comment.
| * `TRY_LOCK_TRX_ID`: The ID of the transaction that tries to add lock, which is the `start_ts` of the transaction. | |
| * `TRY_LOCK_TRX_ID`: The ID of the transaction that tries to acquire the lock, which is the `start_ts` of the transaction. |
| * `CURRENT_SQL_DIGEST`: The digest of the SQL statement currently being executed in the transaction. | ||
| * `STATE`: The current state of the transaction. The possible values include: | ||
| * `Normal`: The transaction is being executed normally or in an idle state. | ||
| * `LockWaiting`: The transaction is waiting for the pessimistic lock to be added. Note that the transaction enters this state at the beginning of the pessimistic locking operation, no matter whether it is blocked by other transactions or not. |
There was a problem hiding this comment.
| * `LockWaiting`: The transaction is waiting for the pessimistic lock to be added. Note that the transaction enters this state at the beginning of the pessimistic locking operation, no matter whether it is blocked by other transactions or not. | |
| * `LockWaiting`: The transaction is waiting for the pessimistic lock to be acquired. Note that the transaction enters this state at the beginning of the pessimistic locking operation, no matter whether it is blocked by other transactions or not. |
|
|
||
| ## CLUSTER_TIDB_TRX | ||
|
|
||
| The `TIDB_TRX` table only provides information about the transactions that are being executed on a single TiDB node. If you want to view the information of the transaction that is being executed on all TiDB nodes in the entire cluster, you need to query the `CLUSTER_TIDB_TRX` table. Compared with the query result of the `TIDB_TRX` table, the query result of the `CLUSTER_TIDB_TRX` table contains an extra `INSTANCE` field. The `INSTANCE` field displays the IP address and port of each node in the cluster, which is used to distinguish the TiDB node where the transaction is located. |
There was a problem hiding this comment.
| The `TIDB_TRX` table only provides information about the transactions that are being executed on a single TiDB node. If you want to view the information of the transaction that is being executed on all TiDB nodes in the entire cluster, you need to query the `CLUSTER_TIDB_TRX` table. Compared with the query result of the `TIDB_TRX` table, the query result of the `CLUSTER_TIDB_TRX` table contains an extra `INSTANCE` field. The `INSTANCE` field displays the IP address and port of each node in the cluster, which is used to distinguish the TiDB node where the transaction is located. | |
| The `TIDB_TRX` table only provides information about the transactions that are being executed on a single TiDB node. If you want to view the information of the transactions that are being executed on all TiDB nodes in the entire cluster, you need to query the `CLUSTER_TIDB_TRX` table. Compared with the query result of the `TIDB_TRX` table, the query result of the `CLUSTER_TIDB_TRX` table contains an extra `INSTANCE` field. The `INSTANCE` field displays the IP address and port of each node in the cluster, which is used to distinguish the TiDB node where the transaction is located. |
A single transaction won't execute on many TiDB nodes.
|
|
||
| #### A few hot keys cause queueing locks | ||
|
|
||
| The `DATA_LOCK_WAITS` system table provides the lock-waiting status on the TiKV node. When you query this table, TiDB automatically obtains the real-time lock-waiting information from all TiKV nodes. If a few hot keys are frequently locked and block many transactions, you can query the `DATA_LOCK_WAITS` table and aggregate the results by key to try to find the key on which issues frequently occur: |
There was a problem hiding this comment.
| The `DATA_LOCK_WAITS` system table provides the lock-waiting status on the TiKV node. When you query this table, TiDB automatically obtains the real-time lock-waiting information from all TiKV nodes. If a few hot keys are frequently locked and block many transactions, you can query the `DATA_LOCK_WAITS` table and aggregate the results by key to try to find the key on which issues frequently occur: | |
| The `DATA_LOCK_WAITS` system table provides the lock-waiting status on the TiKV nodes. When you query this table, TiDB automatically obtains the real-time lock-waiting information from all TiKV nodes. If a few hot keys are frequently locked and block many transactions, you can query the `DATA_LOCK_WAITS` table and aggregate the results by key to try to find the key on which issues frequently occur: |
| 1 row in set (0.01 sec) | ||
| ``` | ||
|
|
||
| If the `start_ts` of the current transaction is unknown, you can try to find out the information of the blocking transaction in the `TIDB_TRX` / `CLUSTER_TIDB_TRX` table or [`PROCESSLIST` / `CLUSTER_PROCESSLIST`](/information-schema/information-schema-processlist.md) table. |
There was a problem hiding this comment.
| If the `start_ts` of the current transaction is unknown, you can try to find out the information of the blocking transaction in the `TIDB_TRX` / `CLUSTER_TIDB_TRX` table or [`PROCESSLIST` / `CLUSTER_PROCESSLIST`](/information-schema/information-schema-processlist.md) table. | |
| If the `start_ts` of the current transaction is unknown, you can try to find it out from the information in the `TIDB_TRX` / `CLUSTER_TIDB_TRX` table or [`PROCESSLIST` / `CLUSTER_PROCESSLIST`](/information-schema/information-schema-processlist.md) table. |
Actually I mean trying to find out the start_ts of the current transaction, and the current transaction is the blocked transaction rather than blocking transaction.
|
My suggestions are just according to my own understandings. They might not make much sense since my English level is kind of limited... so feel free to reject my suggestions if they don't make sense |
|
@MyonKeminta All comments are addressed (accepted). PTAL again, thanks! |
Co-authored-by: MyonKeminta <9948422+MyonKeminta@users.noreply.github.com>
|
@MyonKeminta: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments. DetailsIn response to this: Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
Co-authored-by: Charlotte Liu <37295236+CharLotteiu@users.noreply.github.com>
Co-authored-by: Charlotte Liu <37295236+CharLotteiu@users.noreply.github.com>
|
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. DetailsReviewer can indicate their review by submitting an approval review. |
|
/remove-status LGT1 |
|
/merge |
|
This pull request has been accepted and is ready to merge. DetailsCommit hash: 2a46e69 |
|
In response to a cherrypick label: new pull request created: #5822. |
First-time contributors' checklist
What is changed, added or deleted? (Required)
Add Lock View documents
Which TiDB version(s) do your changes apply to? (Required)
What is the related PR or file link(s)?
Do your changes match any of the following descriptions?