-
Notifications
You must be signed in to change notification settings - Fork 1.2k
docs: add documentation for ADMIN ALTER DDL JOBS command #19085
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
8b32418
docs: add documentation for ADMIN ALTER DDL JOBS command
tangenta db58424
Update sql-statement-admin-alter-ddl.md
hfxsd 8ba0b7e
Update sql-statements/sql-statement-admin-alter-ddl.md
tangenta ee66331
Update sql-statements/sql-statement-admin-alter-ddl.md
tangenta 3187695
docs: clarify parameter value range consistency with system variables…
tangenta c91a9da
Update sql-statements/sql-statement-admin-alter-ddl.md
hfxsd 540be02
Update sql-statements/sql-statement-admin-alter-ddl.md
tangenta 32ad9c1
update admin show ddl jobs doc
tangenta 6d99637
Update TOC.md
hfxsd 42d1e05
address comments
tangenta c0f548f
Update sql-statements/sql-statement-admin-alter-ddl.md
tangenta 24e3cff
Update sql-statements/sql-statement-admin-alter-ddl.md
tangenta 875b4a5
Apply suggestions from code review
hfxsd e92d519
Update sql-statements/sql-statement-admin-alter-ddl.md
hfxsd 33d722b
Apply suggestions from code review
hfxsd 81762e9
Update sql-statements/sql-statement-admin-show-ddl.md
tangenta 004e915
Update sql-statements/sql-statement-admin-alter-ddl.md
tangenta 7d1ba51
Apply suggestions from code review
hfxsd 3aecf54
Apply suggestions from code review
hfxsd ecc162e
Apply suggestions from code review
lilin90 899c438
Update format
lilin90 546eaed
Update sql-statements/sql-statement-admin-alter-ddl.md
hfxsd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
--- | ||
title: ADMIN ALTER DDL JOBS | ||
summary: TiDB 数据库中 `ADMIN ALTER DDL JOBS` 的使用概况。 | ||
--- | ||
|
||
# ADMIN ALTER DDL JOBS | ||
|
||
`ADMIN ALTER DDL JOBS` 语句用于修改单个正在运行的 DDL 作业的相关参数。例如: | ||
|
||
```sql | ||
ADMIN ALTER DDL JOBS 101 THREAD = 8; | ||
``` | ||
|
||
其中: | ||
|
||
- `101`:表示 DDL 作业的 ID,该 ID 可以通过查询 [`ADMIN SHOW DDL JOBS`](/sql-statements/sql-statement-admin-show-ddl.md) 获得。 | ||
- `THREAD`:表示当前 DDL 作业的并发度,其初始值由系统变量 [`tidb_ddl_reorg_worker_cnt`](/system-variables.md#tidb_ddl_reorg_worker_cnt) 设置。 | ||
|
||
目前支持 `ADMIN ALTER DDL JOBS` 的 DDL 作业类型包括:`ADD INDEX`、`MODIFY COLUMN` 和 `REORGANIZE PARTITION`。对于其他 DDL 作业类型,执行 `ADMIN ALTER DDL JOBS` 会报 `unsupported DDL operation` 的错误。 | ||
|
||
目前在一条 `ADMIN ALTER DDL JOBS` 中仅支持对单个 DDL 作业的参数进行调整,不支持同时调整多个 ID 对应的参数。 | ||
|
||
以下是不同 DDL 作业类型支持的各项参数,及其对应的系统变量: | ||
|
||
- `ADD INDEX`: | ||
- `THREAD`:并发度,初始值由系统变量 `tidb_ddl_reorg_worker_cnt` 设置。 | ||
- `BATCH_SIZE`:批大小,初始值由系统变量 [`tidb_ddl_reorg_batch_size`](/system-variables.md#tidb_ddl_reorg_batch_size) 设置。 | ||
- `MAX_WRITE_SPEED`:向每个 TiKV 导入索引记录时的最大带宽限制,初始值由系统变量 [`tidb_ddl_reorg_max_write_speed`](/system-variables.md#tidb_ddl_reorg_max_write_speed-从-v850-版本开始引入) 设置。 | ||
|
||
tangenta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
以上设置,当前仅对关闭 [`tidb_enable_dist_task`](/system-variables.md#tidb_enable_dist_task-从-v710-版本开始引入) 后,提交并运行中的 `ADD INDEX` 的作业生效。 | ||
hfxsd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- `MODIFY COLUMN`: | ||
- `THREAD`:并发度,初始值由系统变量 `tidb_ddl_reorg_worker_cnt` 设置。 | ||
- `BATCH_SIZE`:批大小,初始值由系统变量 `tidb_ddl_reorg_batch_size` 设置。 | ||
|
||
- `REORGANIZE PARTITION`: | ||
- `THREAD`:并发度,初始值由系统变量 `tidb_ddl_reorg_worker_cnt` 设置。 | ||
- `BATCH_SIZE`:批大小,初始值由系统变量 `tidb_ddl_reorg_batch_size` 设置。 | ||
|
||
参数的取值范围和对应系统变量的取值范围保持一致。 | ||
|
||
`ADMIN ALTER DDL JOBS` 仅对正在运行的 DDL 作业生效。如果 DDL 作业不存在或者已经结束,执行该语句会报 `ddl job is not running` 的错误。 | ||
|
||
以下是部分语句示例: | ||
|
||
```sql | ||
ADMIN ALTER DDL JOBS 101 THREAD = 8; | ||
ADMIN ALTER DDL JOBS 101 BATCH_SIZE = 256; | ||
ADMIN ALTER DDL JOBS 101 MAX_WRITE_SPEED = '200MiB'; | ||
ADMIN ALTER DDL JOBS 101 THREAD = 8, BATCH_SIZE = 256; | ||
``` | ||
|
||
要查看某个 DDL 作业当前的参数值,可以执行 `ADMIN SHOW DDL JOBS`,结果显示在 `COMMENTS` 列: | ||
|
||
```sql | ||
admin show ddl jobs 1; | ||
``` | ||
|
||
``` | ||
+--------+---------+------------+-----------+--------------+-----------+----------+-----------+----------------------------+----------------------------+----------------------------+--------+-----------------------+ | ||
| JOB_ID | DB_NAME | TABLE_NAME | JOB_TYPE | SCHEMA_STATE | SCHEMA_ID | TABLE_ID | ROW_COUNT | CREATE_TIME | START_TIME | END_TIME | STATE | COMMENTS | | ||
+--------+---------+------------+-----------+--------------+-----------+----------+-----------+----------------------------+----------------------------+----------------------------+--------+-----------------------+ | ||
| 124 | test | t | add index | public | 2 | 122 | 3 | 2024-11-15 11:17:06.213000 | 2024-11-15 11:17:06.213000 | 2024-11-15 11:17:08.363000 | synced | ingest, DXF, thread=8 | | ||
+--------+---------+------------+-----------+--------------+-----------+----------+-----------+----------------------------+----------------------------+----------------------------+--------+-----------------------+ | ||
1 row in set (0.01 sec) | ||
``` | ||
|
||
## 语法图 | ||
|
||
```ebnf+diagram | ||
AdminAlterDDLStmt ::= | ||
'ADMIN' 'ALTER' 'DDL' 'JOBS' Int64Num AlterJobOptionList | ||
|
||
AlterJobOptionList ::= | ||
AlterJobOption ( ',' AlterJobOption )* | ||
|
||
AlterJobOption ::= | ||
identifier "=" SignedLiteral | ||
``` | ||
|
||
## MySQL 兼容性 | ||
|
||
`ADMIN ALTER DDL JOBS` 语句是 TiDB 对 MySQL 语法的扩展。 | ||
|
||
## 另请参阅 | ||
|
||
* [`ADMIN SHOW DDL [JOBS|QUERIES]`](/sql-statements/sql-statement-admin-show-ddl.md) | ||
* [`ADMIN CANCEL DDL`](/sql-statements/sql-statement-admin-cancel-ddl.md) | ||
* [`ADMIN PAUSE DDL`](/sql-statements/sql-statement-admin-pause-ddl.md) | ||
* [`ADMIN RESUME DDL`](/sql-statements/sql-statement-admin-resume-ddl.md) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.