From 5cf495e4716e7d3f4db9397629418648c38e5233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Wed, 30 Oct 2024 08:50:02 +0100 Subject: [PATCH 1/6] Update docs related to locking --- information-schema/information-schema-data-lock-waits.md | 4 ++++ mysql-schema/mysql-schema.md | 2 +- troubleshoot-lock-conflicts.md | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/information-schema/information-schema-data-lock-waits.md b/information-schema/information-schema-data-lock-waits.md index c6a31fb4a315f..0244ac7b3f03e 100644 --- a/information-schema/information-schema-data-lock-waits.md +++ b/information-schema/information-schema-data-lock-waits.md @@ -89,3 +89,7 @@ CURRENT_HOLDING_TRX_ID: 426790590082449409 ``` The above query result shows that the transaction of the ID `426790594290122753` is trying to obtain the pessimistic lock on the key `"7480000000000000355F728000000000000001"` when executing a statement that has digest `"38b03afa5debbdf0326a014dbe5012a62c51957f1982b3093e748460f8b00821"` and is in the form of ``update `t` set `v` = `v` + ? where `id` = ?``, but the lock on this key was held by the transaction of the ID `426790590082449409`. + +### See also + +- [Troubleshooting lock conflicts](/troubleshoot-lock-conflicts.md) \ No newline at end of file diff --git a/mysql-schema/mysql-schema.md b/mysql-schema/mysql-schema.md index 96d9adba68921..976ec5761cece 100644 --- a/mysql-schema/mysql-schema.md +++ b/mysql-schema/mysql-schema.md @@ -84,7 +84,7 @@ Currently, the `help_topic` is NULL. ## System tables related to metadata locks -* `tidb_mdl_view`: a view of metadata locks. You can use it to view information about the currently blocked DDL statements +* `tidb_mdl_view`: a view of metadata locks. You can use it to view information about the currently blocked DDL statements. See also [Metadata Lock](/metadata-lock.md) * `tidb_mdl_info`: used internally by TiDB to synchronize metadata locks across nodes ## System tables related to DDL statements diff --git a/troubleshoot-lock-conflicts.md b/troubleshoot-lock-conflicts.md index fc1399896168c..a04bbdb74427a 100644 --- a/troubleshoot-lock-conflicts.md +++ b/troubleshoot-lock-conflicts.md @@ -159,6 +159,12 @@ In the above query, the [`TIDB_DECODE_SQL_DIGESTS`](/functions-and-operators/tid 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 in the [`PROCESSLIST` / `CLUSTER_PROCESSLIST`](/information-schema/information-schema-processlist.md) table. +### Metadata locks + +When a session is waiting on a schema change this can be because of a metadata lock. + +See [Metadata locks](/metadata-lock.md) for more information. + ## Troubleshoot optimistic lock conflicts This section provides the solutions of common lock conflict issues in the optimistic transaction mode. From 1f324bfd3d216d85a6bef91edd6b41c31250a51f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Thu, 31 Oct 2024 08:32:26 +0100 Subject: [PATCH 2/6] Update for tidbcloud --- .../information-schema-data-lock-waits.md | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/information-schema/information-schema-data-lock-waits.md b/information-schema/information-schema-data-lock-waits.md index 0244ac7b3f03e..5ba7cd262b421 100644 --- a/information-schema/information-schema-data-lock-waits.md +++ b/information-schema/information-schema-data-lock-waits.md @@ -7,14 +7,12 @@ summary: Learn the `DATA_LOCK_WAITS` information_schema table. The `DATA_LOCK_WAITS` table shows the ongoing lock-wait information on all TiKV nodes in a cluster, including the lock-wait information of pessimistic transactions and the information of optimistic transactions being blocked. -{{< copyable "sql" >}} - ```sql USE information_schema; DESC data_lock_waits; ``` -```sql +``` +------------------------+---------------------+------+------+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------------+---------------------+------+------+---------+-------+ @@ -71,13 +69,11 @@ In the above fields, if the information of a field is not applicable or currentl ## Example -{{< copyable "sql" >}} - ```sql select * from information_schema.data_lock_waits\G ``` -```sql +``` *************************** 1. row *************************** KEY: 7480000000000000355F728000000000000001 KEY_INFO: {"db_id":1,"db_name":"test","table_id":53,"table_name":"t","handle_type":"int","handle_value":"1"} @@ -92,4 +88,14 @@ The above query result shows that the transaction of the ID `426790594290122753` ### See also -- [Troubleshooting lock conflicts](/troubleshoot-lock-conflicts.md) \ No newline at end of file + + +- [Troubleshooting lock conflicts](/troubleshoot-lock-conflicts.md) + + + + + +- [Handle Transaction Errors](/develop/dev-guide-transaction-troubleshoot.md) + + \ No newline at end of file From 33b58412269d9760b0972a51e1dc8c9ce925c50b Mon Sep 17 00:00:00 2001 From: Lilian Lee Date: Tue, 5 Nov 2024 15:39:35 +0800 Subject: [PATCH 3/6] Update punctuation and wording --- troubleshoot-lock-conflicts.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/troubleshoot-lock-conflicts.md b/troubleshoot-lock-conflicts.md index a04bbdb74427a..686c7c92305f5 100644 --- a/troubleshoot-lock-conflicts.md +++ b/troubleshoot-lock-conflicts.md @@ -161,9 +161,9 @@ If the `start_ts` of the current transaction is unknown, you can try to find it ### Metadata locks -When a session is waiting on a schema change this can be because of a metadata lock. +When a session is waiting on a schema change, this can be because of a metadata lock. -See [Metadata locks](/metadata-lock.md) for more information. +See [Metadata Lock](/metadata-lock.md) for more information. ## Troubleshoot optimistic lock conflicts From bed22012e7eda450023212669648f4ea29fd429b Mon Sep 17 00:00:00 2001 From: Lilian Lee Date: Tue, 5 Nov 2024 16:05:20 +0800 Subject: [PATCH 4/6] Apply suggestions from code review --- information-schema/information-schema-data-lock-waits.md | 2 +- mysql-schema/mysql-schema.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/information-schema/information-schema-data-lock-waits.md b/information-schema/information-schema-data-lock-waits.md index 5ba7cd262b421..a10b62dd773e1 100644 --- a/information-schema/information-schema-data-lock-waits.md +++ b/information-schema/information-schema-data-lock-waits.md @@ -90,7 +90,7 @@ The above query result shows that the transaction of the ID `426790594290122753` -- [Troubleshooting lock conflicts](/troubleshoot-lock-conflicts.md) +- [Troubleshoot Lock Conflicts](/troubleshoot-lock-conflicts.md) diff --git a/mysql-schema/mysql-schema.md b/mysql-schema/mysql-schema.md index 976ec5761cece..797878f23db0d 100644 --- a/mysql-schema/mysql-schema.md +++ b/mysql-schema/mysql-schema.md @@ -84,8 +84,8 @@ Currently, the `help_topic` is NULL. ## System tables related to metadata locks -* `tidb_mdl_view`: a view of metadata locks. You can use it to view information about the currently blocked DDL statements. See also [Metadata Lock](/metadata-lock.md) -* `tidb_mdl_info`: used internally by TiDB to synchronize metadata locks across nodes +* `tidb_mdl_view`: a view of metadata locks. You can use it to view information about the currently blocked DDL statements. See also [Metadata Lock](/metadata-lock.md). +* `tidb_mdl_info`: used internally by TiDB to synchronize metadata locks across nodes. ## System tables related to DDL statements From 1e4f33b198ad6c1cb89c4465984a3a22cc4fce02 Mon Sep 17 00:00:00 2001 From: Lilian Lee Date: Tue, 5 Nov 2024 16:08:29 +0800 Subject: [PATCH 5/6] Update troubleshoot-lock-conflicts.md --- troubleshoot-lock-conflicts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/troubleshoot-lock-conflicts.md b/troubleshoot-lock-conflicts.md index 686c7c92305f5..9267104f45ed5 100644 --- a/troubleshoot-lock-conflicts.md +++ b/troubleshoot-lock-conflicts.md @@ -161,7 +161,7 @@ If the `start_ts` of the current transaction is unknown, you can try to find it ### Metadata locks -When a session is waiting on a schema change, this can be because of a metadata lock. +If a session is waiting on a schema change, this can be because of a metadata lock. See [Metadata Lock](/metadata-lock.md) for more information. From add64671fd18a1855710b46e183b54cc7c0e8303 Mon Sep 17 00:00:00 2001 From: Lilian Lee Date: Tue, 5 Nov 2024 16:09:46 +0800 Subject: [PATCH 6/6] Update format --- information-schema/information-schema-data-lock-waits.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/information-schema/information-schema-data-lock-waits.md b/information-schema/information-schema-data-lock-waits.md index a10b62dd773e1..bc0dc4f425bec 100644 --- a/information-schema/information-schema-data-lock-waits.md +++ b/information-schema/information-schema-data-lock-waits.md @@ -86,7 +86,7 @@ CURRENT_HOLDING_TRX_ID: 426790590082449409 The above query result shows that the transaction of the ID `426790594290122753` is trying to obtain the pessimistic lock on the key `"7480000000000000355F728000000000000001"` when executing a statement that has digest `"38b03afa5debbdf0326a014dbe5012a62c51957f1982b3093e748460f8b00821"` and is in the form of ``update `t` set `v` = `v` + ? where `id` = ?``, but the lock on this key was held by the transaction of the ID `426790590082449409`. -### See also +## See also