-
Notifications
You must be signed in to change notification settings - Fork 710
docs: update PLAN REPLAYER object storage behavior #22557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -20,6 +20,8 @@ You can use `PLAN REPLAYER` to save the on-site information of a TiDB cluster. T | |||||
| PLAN REPLAYER DUMP [WITH STATS AS OF TIMESTAMP expression] EXPLAIN [ANALYZE] sql-statement; | ||||||
| ``` | ||||||
|
|
||||||
| By default, TiDB stores files generated by `PLAN REPLAYER` in local storage. If you set [`tidb_cloud_storage_uri`](/system-variables.md#tidb_cloud_storage_uri-new-in-v740) to a valid external storage URI, TiDB stores the generated `ZIP` files in the specified storage. For supported URI formats, see [URI Formats of External Storage Services](/external-storage-uri.md). | ||||||
|
|
||||||
| Based on `sql-statement`, TiDB sorts out and exports the following on-site information: | ||||||
|
|
||||||
| - TiDB version | ||||||
|
|
@@ -54,11 +56,14 @@ plan replayer dump with stats as of timestamp '2023-07-17 12:00:00' explain sele | |||||
| plan replayer dump with stats as of timestamp '442012134592479233' explain select * from t; | ||||||
| ``` | ||||||
|
|
||||||
| `PLAN REPLAYER DUMP` packages the table information above into a `ZIP` file and returns the file identifier as the execution result. | ||||||
| `PLAN REPLAYER DUMP` packages the table information above into a `ZIP` file and returns the download information as the execution result: | ||||||
|
|
||||||
| - If the configured storage backend supports presigned URLs, TiDB returns a presigned URL. | ||||||
| - Otherwise, TiDB returns a file token. | ||||||
|
|
||||||
| > **Note:** | ||||||
| > | ||||||
| > The `ZIP` file is stored in a TiDB cluster for at most one hour. After one hour, TiDB will delete it. | ||||||
| > The result file is kept for at most one hour. After one hour, TiDB deletes it from the corresponding local or external storage. | ||||||
|
|
||||||
| ```sql | ||||||
| MySQL [test]> plan replayer dump explain select * from t; | ||||||
|
|
@@ -88,6 +93,17 @@ SELECT @@tidb_last_plan_replayer_token; | |||||
| 1 row in set (0.00 sec) | ||||||
| ``` | ||||||
|
|
||||||
| If the configured storage backend supports presigned URLs, the result returned by `PLAN REPLAYER DUMP` or `@@tidb_last_plan_replayer_token` is a presigned URL instead of a file token. For example: | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ```sql | ||||||
| +----------------------------------------------------------------------------------------------------------------------+ | ||||||
| | Dump_link | | ||||||
| +----------------------------------------------------------------------------------------------------------------------+ | ||||||
| | https://storage.example.com/replayer_xxx.zip?X-Amz-Algorithm=...&X-Amz-Credential=...&X-Amz-Signature=... | | ||||||
| +----------------------------------------------------------------------------------------------------------------------+ | ||||||
| 1 row in set (0.00 sec) | ||||||
| ``` | ||||||
|
|
||||||
| When there are multiple SQL statements, you can obtain the result of the `PLAN REPLAYER DUMP` execution using a file. The results of multiple SQL statements are separated by `;` in this file. | ||||||
|
|
||||||
| ```sql | ||||||
|
|
@@ -111,7 +127,17 @@ SELECT @@tidb_last_plan_replayer_token; | |||||
| 1 row in set (0.00 sec) | ||||||
| ``` | ||||||
|
|
||||||
| Because the file cannot be downloaded on MySQL Client, you need to use the TiDB HTTP interface and the file identifier to download the file: | ||||||
| If `PLAN REPLAYER DUMP` returns a presigned URL, you can use the URL directly to download the file: | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| {{< copyable "shell-regular" >}} | ||||||
|
|
||||||
| ```shell | ||||||
| curl "${presigned_url}" > plan_replayer.zip | ||||||
| ``` | ||||||
|
|
||||||
| The presigned URL is valid for up to one hour. | ||||||
|
Comment on lines
+137
to
+138
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| If `PLAN REPLAYER DUMP` returns a file token, you need to use the TiDB HTTP interface and the file token to download the file: | ||||||
|
|
||||||
| {{< copyable "shell-regular" >}} | ||||||
|
|
||||||
|
|
@@ -261,11 +287,13 @@ mysql> SELECT * FROM mysql.plan_replayer_status; | |||||
| 3 rows in set (0.00 sec) | ||||||
| ``` | ||||||
|
|
||||||
| The method of downloading the file of `PLAN REPLAYER CAPTURE` is the same as that of `PLAN REPLAYER`. For details, see [Examples of exporting cluster information](#examples-of-exporting-cluster-information). | ||||||
| If [`tidb_cloud_storage_uri`](/system-variables.md#tidb_cloud_storage_uri-new-in-v740) is configured, the captured file is also stored in the configured external storage. The `token` column in the `mysql.plan_replayer_status` table still records the file token of the generated capture file. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| To download the file of `PLAN REPLAYER CAPTURE`, use the value in the `token` column of `mysql.plan_replayer_status` together with the TiDB HTTP interface. This is the same as the file-token based download flow described in [Examples of exporting cluster information](#examples-of-exporting-cluster-information). | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| > **Note:** | ||||||
| > | ||||||
| > The result file of `PLAN REPLAYER CAPTURE` is kept in the TiDB cluster for up to one week. After one week, TiDB deletes the file. | ||||||
| > The result file of `PLAN REPLAYER CAPTURE` is kept for up to one week. After one week, TiDB deletes it from the corresponding local or external storage. | ||||||
|
|
||||||
| ### Remove the capture tasks | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1725,10 +1725,11 @@ mysql> SELECT job_info FROM mysql.analyze_jobs ORDER BY end_time DESC LIMIT 1; | |||||
| - Persists to cluster: Yes | ||||||
| - Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No | ||||||
| - Default value: `""` | ||||||
| - This variable is used to specify the Amazon S3 cloud storage URI to enable [Global Sort](/tidb-global-sort.md). After enabling the [TiDB Distributed eXecution Framework (DXF)](/tidb-distributed-execution-framework.md), you can use the Global Sort feature by configuring the URI and pointing it to an appropriate cloud storage path with the necessary permissions to access the storage. For more details, see [Amazon S3 URI format](/external-storage-uri.md#amazon-s3-uri-format). | ||||||
| - The following statements can use the Global Sort feature. | ||||||
| - This variable is used to specify the cloud storage URI for TiDB features that use external storage. After enabling the [TiDB Distributed eXecution Framework (DXF)](/tidb-distributed-execution-framework.md), you can use the [Global Sort](/tidb-global-sort.md) feature by configuring the URI and pointing it to an appropriate cloud storage path with the necessary permissions to access the storage. [`PLAN REPLAYER`](/sql-plan-replayer.md) also uses this URI to store the generated files. If this variable is empty, `PLAN REPLAYER` uses local storage. For URI formats, see [URI Formats of External Storage Services](/external-storage-uri.md). | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| - The following statements or features can use this variable. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| - The [`ADD INDEX`](/sql-statements/sql-statement-add-index.md) statement. | ||||||
| - The [`IMPORT INTO`](/sql-statements/sql-statement-import-into.md) statement for import jobs. | ||||||
| - [`PLAN REPLAYER`](/sql-plan-replayer.md), including files generated by `PLAN REPLAYER DUMP`, `PLAN REPLAYER CAPTURE`, and `PLAN REPLAYER CONTINUOUS CAPTURE`. | ||||||
|
|
||||||
| ### tidb_ddl_error_count_limit | ||||||
|
|
||||||
|
|
@@ -3701,7 +3702,7 @@ For a system upgraded to v5.0 from an earlier version, if you have not modified | |||||
| - Scope: SESSION | ||||||
| - Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No | ||||||
| - Type: String | ||||||
| - This variable is read-only and is used to obtain the result of the last `PLAN REPLAYER DUMP` execution in the current session. | ||||||
| - This variable is read-only and is used to obtain the result of the last `PLAN REPLAYER DUMP` execution in the current session. The result is either a file token or, if the configured storage backend supports it, a presigned URL. | ||||||
|
|
||||||
| ### tidb_load_based_replica_read_threshold <span class="version-mark">New in v7.0.0</span> | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.