-
Notifications
You must be signed in to change notification settings - Fork 716
dxf: document ADD INDEX disk space precheck #23190
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 1 commit
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -525,6 +525,17 @@ For more possible values of this variable, see [Authentication plugin status](/s | |||||
| - Default value: `0` | ||||||
| - A read-only variable that indicates the number of errors that resulted from the last statement that generated messages. | ||||||
|
|
||||||
| ### enforce_disk_space_precheck_before_add_index | ||||||
|
|
||||||
| - Scope: GLOBAL | ||||||
| - Persists to cluster: Yes | ||||||
| - Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No | ||||||
| - Type: Boolean | ||||||
| - Default value: `OFF` | ||||||
| - This variable controls whether TiDB rejects a DXF [`ADD INDEX`](/sql-statements/sql-statement-add-index.md) task when the TiKV disk space precheck predicts insufficient TiKV capacity. | ||||||
| - When the value is `OFF`, TiDB still performs the precheck and logs warnings for insufficient TiKV capacity, but it does not reject the DDL job. | ||||||
| - When the value is `ON`, TiDB rejects the DDL job if the precheck predicts insufficient TiKV capacity and the prediction uses non-pseudo table statistics. If the prediction uses pseudo statistics, TiDB logs a warning and does not reject the DDL job. For more information, see [TiKV disk space precheck for `ADD INDEX` tasks](/tidb-distributed-execution-framework.md#tikv-disk-space-precheck-for-add-index-tasks). | ||||||
|
Contributor
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. To maintain consistency with the rest of the documentation, use the term 'non-pseudo statistics' instead of 'non-pseudo table statistics'.
Suggested change
References
|
||||||
|
|
||||||
| ### foreign_key_checks | ||||||
|
|
||||||
| - Scope: SESSION | GLOBAL | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -89,6 +89,25 @@ | |||||
| * [`tidb_ddl_error_count_limit`](/system-variables.md#tidb_ddl_error_count_limit) | ||||||
| * [`tidb_ddl_reorg_batch_size`](/system-variables.md#tidb_ddl_reorg_batch_size): use the default value. The recommended maximum value is `1024`. | ||||||
|
|
||||||
| ## TiKV disk space precheck for `ADD INDEX` tasks | ||||||
|
|
||||||
| For [`ADD INDEX`](/sql-statements/sql-statement-add-index.md) tasks executed by the DXF, TiDB collects a TiKV capacity snapshot before submitting the distributed task, predicts the TiKV index size based on block sampling, table statistics, and the replica count, and then checks whether TiKV has enough remaining disk space for the task. This precheck applies to both local sort and Global Sort execution paths. | ||||||
|
Check warning on line 94 in tidb-distributed-execution-framework.md
|
||||||
|
|
||||||
| TiDB considers TiKV disk space insufficient if either of the following conditions is met: | ||||||
|
Contributor
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. Simplify the sentence and avoid passive voice ('is met') by using 'in either of the following cases:'.
Suggested change
References
|
||||||
|
|
||||||
| - After subtracting the predicted index size, the remaining TiKV cluster capacity is less than 20% of the total TiKV cluster capacity. | ||||||
| - After subtracting the per-store predicted index size, the remaining capacity of any TiKV store is less than 15% of that store's total capacity. | ||||||
|
|
||||||
| By default, [`enforce_disk_space_precheck_before_add_index`](/system-variables.md#enforce_disk_space_precheck_before_add_index) is `OFF`. In this mode, TiDB logs a warning if the precheck predicts insufficient TiKV capacity, but it still submits the DDL job. To reject such DDL jobs before task submission, set this variable to `ON`: | ||||||
|
|
||||||
| ```sql | ||||||
| SET GLOBAL enforce_disk_space_precheck_before_add_index = ON; | ||||||
| ``` | ||||||
|
|
||||||
| When this variable is `ON`, TiDB rejects the DDL job only if the prediction uses non-pseudo table statistics. If the prediction uses pseudo statistics, TiDB logs a warning and does not reject the DDL job. If TiDB cannot collect the TiKV capacity snapshot or complete the prediction within 5 seconds, TiDB logs a warning, skips the precheck, and continues to submit the DDL job. | ||||||
|
Contributor
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. Improve clarity and conciseness by changing 'non-pseudo table statistics' to 'non-pseudo statistics' for consistency, replacing the repetitive use of 'TiDB' with 'it', and simplifying 'continues to submit' to 'submits'.
Suggested change
References
|
||||||
|
|
||||||
| To observe the predicted and actual TiKV storage usage of a DXF `ADD INDEX` task, check the TiDB logs. TiDB logs prediction fields such as `block_sample_predicted_tikv_index_all_replica_bytes`, `block_sample_predicted_tikv_index_single_replica_bytes`, and `block_sample_mvcc_overhead_total_bytes` at task submission time. After the task succeeds, TiDB also logs fields such as `logical_index_kv_bytes`, `ingested_sst_bytes`, `ingested_sst_bytes_source`, and `ingested_sst_bytes_reliable`. | ||||||
|
|
||||||
| ## Task scheduling | ||||||
|
|
||||||
| By default, the DXF schedules all TiDB nodes to execute distributed tasks. Starting from v7.4.0, for TiDB Self-Managed clusters, you can control which TiDB nodes can be scheduled by the DXF to execute distributed tasks by configuring [`tidb_service_scope`](/system-variables.md#tidb_service_scope-new-in-v740). | ||||||
|
|
@@ -128,4 +147,4 @@ | |||||
|
|
||||||
| * [Execution Principles and Best Practices of DDL Statements](https://docs.pingcap.com/tidb/stable/ddl-introduction) | ||||||
|
|
||||||
| </CustomContent> | ||||||
| </CustomContent> | ||||||
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.
Only apply to DXF?
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.
It will apply to both DXF and classic. Should I write doc now that it will apply for both envs?