Skip to content

Add Lock View documents#5798

Merged
ti-chi-bot merged 11 commits into
pingcap:masterfrom
TomShawn:lock-view-docs
Jun 22, 2021
Merged

Add Lock View documents#5798
ti-chi-bot merged 11 commits into
pingcap:masterfrom
TomShawn:lock-view-docs

Conversation

@TomShawn
Copy link
Copy Markdown
Contributor

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)

  • master (the latest development version)
  • v5.1 (TiDB 5.1 versions)
  • v5.0 (TiDB 5.0 versions)
  • v4.0 (TiDB 4.0 versions)
  • v3.1 (TiDB 3.1 versions)
  • v3.0 (TiDB 3.0 versions)
  • v2.1 (TiDB 2.1 versions)

What is the related PR or file link(s)?

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

@TomShawn TomShawn added translation/from-docs-cn This PR is translated from a PR in pingcap/docs-cn. v5.1 This PR/issue applies to TiDB v5.1. labels Jun 16, 2021
@ti-chi-bot ti-chi-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jun 16, 2021
Comment thread troubleshoot-lock-conflicts.md Outdated
Comment thread information-schema/information-schema-data-lock-waits.md Outdated
Comment thread information-schema/information-schema-data-lock-waits.md Outdated
Comment thread information-schema/information-schema-data-lock-waits.md Outdated
Comment thread information-schema/information-schema-data-lock-waits.md Outdated
Comment thread information-schema/information-schema-data-lock-waits.md Outdated
Comment thread information-schema/information-schema-deadlocks.md Outdated
Comment thread information-schema/information-schema-deadlocks.md Outdated
Comment thread information-schema/information-schema-deadlocks.md Outdated
Comment thread information-schema/information-schema-tidb-trx.md Outdated
Comment thread information-schema/information-schema-tidb-trx.md Outdated
@TomShawn TomShawn marked this pull request as ready for review June 17, 2021 05:20
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 17, 2021

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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the context of displaying a long byte array, maybe calling it "hexadecimal string" looks better than "hexadecimal code"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

> **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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comparing to the word "necessarily", I think maybe "guaranteed" or "promised" looks more clear?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

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`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Comment thread troubleshoot-lock-conflicts.md
Comment thread troubleshoot-lock-conflicts.md Outdated

#### 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:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:

Comment thread troubleshoot-lock-conflicts.md Outdated
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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

@MyonKeminta
Copy link
Copy Markdown
Contributor

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

@TomShawn
Copy link
Copy Markdown
Contributor Author

@MyonKeminta All comments are addressed (accepted). PTAL again, thanks!

@TomShawn TomShawn requested a review from MyonKeminta June 18, 2021 03:50
Copy link
Copy Markdown
Contributor

@MyonKeminta MyonKeminta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest LGTM

Comment thread information-schema/information-schema-data-lock-waits.md Outdated
Co-authored-by: MyonKeminta <9948422+MyonKeminta@users.noreply.github.com>
@ti-chi-bot
Copy link
Copy Markdown
Member

@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.

Details

In 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.

Copy link
Copy Markdown
Contributor

@CharLotteiu CharLotteiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments.

Comment thread information-schema/information-schema-data-lock-waits.md Outdated
Comment thread information-schema/information-schema-data-lock-waits.md Outdated
Comment thread information-schema/information-schema-deadlocks.md Outdated
Comment thread information-schema/information-schema-deadlocks.md Outdated
Comment thread information-schema/information-schema-deadlocks.md Outdated
Comment thread tidb-configuration-file.md Outdated
Comment thread troubleshoot-lock-conflicts.md Outdated
Comment thread troubleshoot-lock-conflicts.md Outdated
Comment thread troubleshoot-lock-conflicts.md Outdated
Comment thread troubleshoot-lock-conflicts.md Outdated
Co-authored-by: Charlotte Liu <37295236+CharLotteiu@users.noreply.github.com>
Co-authored-by: Charlotte Liu <37295236+CharLotteiu@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@CharLotteiu CharLotteiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ti-chi-bot
Copy link
Copy Markdown
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • CharLotteiu

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Details

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jun 22, 2021
@TomShawn
Copy link
Copy Markdown
Contributor Author

/remove-status LGT1
/status LGT2

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jun 22, 2021
@TomShawn
Copy link
Copy Markdown
Contributor Author

/merge

@ti-chi-bot
Copy link
Copy Markdown
Member

This pull request has been accepted and is ready to merge.

DetailsCommit hash: 2a46e69

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jun 22, 2021
@ti-chi-bot ti-chi-bot merged commit 83f5b40 into pingcap:master Jun 22, 2021
@TomShawn TomShawn deleted the lock-view-docs branch June 22, 2021 09:05
@ti-chi-bot ti-chi-bot mentioned this pull request Jun 22, 2021
11 tasks
@ti-chi-bot
Copy link
Copy Markdown
Member

In response to a cherrypick label: new pull request created: #5822.

ti-chi-bot added a commit that referenced this pull request Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. translation/from-docs-cn This PR is translated from a PR in pingcap/docs-cn. v5.1 This PR/issue applies to TiDB v5.1.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants