You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
summary: An overview of the usage of `ADMIN ALTER DDL JOBS` for the TiDB database.
4
+
---
5
+
6
+
# ADMIN ALTER DDL JOBS
7
+
8
+
The `ADMIN ALTER DDL JOBS` statement allows you to modify the parameter of a single running DDL job. For example:
9
+
10
+
```sql
11
+
ADMIN ALTER DDL JOBS 101 THREAD =8;
12
+
```
13
+
14
+
-`101`: indicates the ID of the DDL job. You can obtain the ID by executing [`ADMIN SHOW DDL JOBS`](/sql-statements/sql-statement-admin-show-ddl.md).
15
+
-`THREAD`: indicates the concurrency of the DDL job. You can configure its initial value using the system variable [`tidb_ddl_reorg_worker_cnt`](/system-variables.md#tidb_ddl_reorg_worker_cnt).
16
+
17
+
The DDL job types supported by the `ADMIN ALTER DDL JOBS` statement include `ADD INDEX`, `MODIFY COLUMN`, and `REORGANIZE PARTITION`. For other DDL job types, executing `ADMIN ALTER DDL JOBS` returns the `unsupported DDL operation` error.
18
+
19
+
Currently, you can only modify the parameters of a single DDL job by executing `ADMIN ALTER DDL JOBS`. Modifying the parameters of multiple DDL job IDs at the same time is not supported.
20
+
21
+
The following are the supported parameters for different DDL jobs and their corresponding system variables:
22
+
23
+
-`ADD INDEX`:
24
+
-`THREAD`: the concurrency of the DDL job. The initial value is set by `tidb_ddl_reorg_worker_cnt`.
25
+
-`BATCH_SIZE`: the batch size. The initial value is set by [`tidb_ddl_reorg_batch_size`](/system-variables.md#tidb_ddl_reorg_batch_size).
26
+
-`MAX_WRITE_SPEED`: the maximum bandwidth limit for importing index records into each TiKV. The initial value is set by [`tidb_ddl_reorg_max_write_speed`](/system-variables.md#tidb_ddl_reorg_max_write_speed-new-in-v850).
27
+
28
+
Currently, the preceding parameters only work for `ADD INDEX` jobs that are submitted and running after [`tidb_enable_dist_task`](/system-variables.md#tidb_enable_dist_task-new-in-v710) is disabled.
29
+
30
+
-`MODIFY COLUMN`:
31
+
-`THREAD`: the concurrency of the DDL job. The initial value is set by `tidb_ddl_reorg_worker_cnt`.
32
+
-`BATCH_SIZE`: the batch size. The initial value is set by `tidb_ddl_reorg_batch_size`.
33
+
34
+
-`REORGANIZE PARTITION`:
35
+
-`THREAD`: the concurrency of the DDL job. The initial value is set by `tidb_ddl_reorg_worker_cnt`.
36
+
-`BATCH_SIZE`: the batch size. The initial value is set by `tidb_ddl_reorg_batch_size`.
37
+
38
+
The value ranges of the preceding parameters are consistent with those of the corresponding system variables.
39
+
40
+
`ADMIN ALTER DDL JOBS` takes effect only on running DDL jobs. If the DDL job does not exist or has already completed, executing this statement returns the `ddl job is not running` error.
41
+
42
+
The following are some examples of this statement:
43
+
44
+
```sql
45
+
ADMIN ALTER DDL JOBS 101 THREAD =8;
46
+
ADMIN ALTER DDL JOBS 101 BATCH_SIZE =256;
47
+
ADMIN ALTER DDL JOBS 101 MAX_WRITE_SPEED ='200MiB';
48
+
ADMIN ALTER DDL JOBS 101 THREAD =8, BATCH_SIZE =256;
49
+
```
50
+
51
+
To view the current parameter values for a specific DDL job, you can execute `ADMIN SHOW DDL JOBS`. The results are displayed in the `COMMENTS` column:
Copy file name to clipboardExpand all lines: sql-statements/sql-statement-admin-show-ddl.md
+37-29Lines changed: 37 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,9 +12,9 @@ The `ADMIN SHOW DDL [JOBS|JOB QUERIES]` statement shows information about runnin
12
12
```ebnf+diagram
13
13
AdminShowDDLStmt ::=
14
14
'ADMIN' 'SHOW' 'DDL'
15
-
(
16
-
'JOBS' Int64Num? WhereClauseOptional
17
-
| 'JOB' 'QUERIES' NumList
15
+
(
16
+
'JOBS' Int64Num? WhereClauseOptional
17
+
| 'JOB' 'QUERIES' NumList
18
18
| 'JOB' 'QUERIES' 'LIMIT' m ( ('OFFSET' | ',') n )?
19
19
)?
20
20
@@ -47,15 +47,15 @@ ADMIN SHOW DDL\G;
47
47
SCHEMA_VER: 26
48
48
OWNER_ID: 2d1982af-fa63-43ad-a3d5-73710683cc63
49
49
OWNER_ADDRESS: 0.0.0.0:4000
50
-
RUNNING_JOBS:
50
+
RUNNING_JOBS:
51
51
SELF_ID: 2d1982af-fa63-43ad-a3d5-73710683cc63
52
-
QUERY:
52
+
QUERY:
53
53
1 row inset (0.00 sec)
54
54
```
55
55
56
56
### `ADMIN SHOW DDL JOBS`
57
57
58
-
The `ADMIN SHOW DDL JOBS` statement is used to view all the results in the current DDL job queue, including running and queuing tasks, as well as the latest ten results in the completed DDL job queue. The returned result fields are described as follows:
58
+
The `ADMIN SHOW DDL JOBS` statement is used to view the 10 jobs in the current DDL job queue, including running and pending jobs (if any), and the last 10 jobs in the executed DDL job queue (if any). The returned result fields are described as follows:
59
59
60
60
<CustomContentplatform="tidb">
61
61
@@ -66,9 +66,7 @@ The `ADMIN SHOW DDL JOBS` statement is used to view all the results in the curre
66
66
-`create schema`: for [`CREATE SCHEMA`](/sql-statements/sql-statement-create-database.md) operations.
67
67
-`create table`: for [`CREATE TABLE`](/sql-statements/sql-statement-create-table.md) operations.
68
68
-`create view`: for [`CREATE VIEW`](/sql-statements/sql-statement-create-view.md) operations.
69
-
-`ingest`: ingestion with accelerated index backfilling as configured by [`tidb_ddl_enable_fast_reorg`](/system-variables.md#tidb_ddl_enable_fast_reorg-new-in-v630).
70
-
-`txn`: basic transactional backfilling.
71
-
-`add index /* txn-merge */`: transactional backfilling with a temporary index that gets merged with the original index when the backfilling is finished.
69
+
-`add index`: for [`ADD INDEX`](/sql-statements/sql-statement-add-index.md) operations.
72
70
-`SCHEMA_STATE`: the current state of the schema object that the DDL operates on. If `JOB_TYPE` is `ADD INDEX`, it is the state of the index; if `JOB_TYPE` is `ADD COLUMN`, it is the state of the column; if `JOB_TYPE` is `CREATE TABLE`, it is the state of the table. Common states include the following:
73
71
-`none`: indicates that it does not exist. Generally, after the `DROP` operation or after the `CREATE` operation fails and rolls back, it will become the `none` state.
74
72
-`delete only`, `write only`, `delete reorganization`, `write reorganization`: these four states are intermediate states. For their specific meanings, see [How the Online DDL Asynchronous Change Works in TiDB](/ddl-introduction.md#how-the-online-ddl-asynchronous-change-works-in-tidb). As the intermediate state conversion is fast, these states are generally not visible during operation. Only when performing `ADD INDEX` operation can the `write reorganization` state be seen, indicating that index data is being added.
@@ -91,6 +89,15 @@ The `ADMIN SHOW DDL JOBS` statement is used to view all the results in the curre
91
89
-`pausing`: indicates that the operation is being paused.
92
90
-`paused`: indicates that the operation has been paused. This state only appears when you use the [`ADMIN PAUSED DDL JOBS`](/sql-statements/sql-statement-admin-pause-ddl.md) command to pause the DDL job. You can use the [`ADMIN RESUME DDL JOBS`](/sql-statements/sql-statement-admin-resume-ddl.md) command to resume the DDL job.
93
91
-`done`: indicates that the operation has been successfully executed on the TiDB owner node, but other TiDB nodes have not yet synchronized the changes performed by this DDL job.
92
+
-`COMMENTS`: contains additional information for diagnostic purposes.
93
+
-`ingest`: ingest tasks for accelerated adding index backfill configured via [`tidb_ddl_enable_fast_reorg`](/system-variables.md#tidb_ddl_enable_fast_reorg-new-in-v630)。
94
+
-`txn`: transaction-based index backfill after [`tidb_ddl_enable_fast_reorg`](/system-variables.md#tidb_ddl_enable_fast_reorg-new-in-v630) is disabled.
95
+
-`txn-merge`: transactional backfilling with a temporary index that gets merged with the original index when the backfilling is finished.
96
+
-`DXF`: tasks executed with Distributed eXecution Framework (DXF) configured via [`tidb_enable_dist_task`](/system-variables.md#tidb_enable_dist_task-new-in-v710).
97
+
-`service_scope`: the service scope of the TiDB node configured via [`tidb_service_scope`](/system-variables.md#tidb_service_scope-new-in-v740).
98
+
-`thread`: the concurrency of backfill tasks. You can set the initial value by `tidb_ddl_reorg_worker_cnt`. It supports dynamic modification via [`ADMIN ALTER DDL JOBS`](/sql-statements/sql-statement-admin-alter-ddl.md).
99
+
-`batch_size`: the batch size of backfill tasks. You can set the initial value by `tidb_ddl_reorg_batch_size`. It supports dynamic modification via `ADMIN ALTER DDL JOBS`.
100
+
-`max_write_speed`: flow control during ingest task import. The initial value can be set with `tidb_ddl_reorg_max_write_speed`. It supports dynamic modification via `ADMIN ALTER DDL JOBS`.
- Job 59 is currently in progress (`STATE` of `running`). The schema state is currently in `write reorganization`, but will switch to `public` once the task is completed to note that the change can be observed publicly by user sessions. The `end_time` column is also `NULL` indicating that the completion time for the job is currently not known.
159
+
- Job 565 is currently in progress (`STATE` of `running`). The schema state is currently in `write reorganization`, but will switch to `public` once the job is completed to note that the change can be observed publicly by user sessions. The `end_time` column is also `NULL` indicating that the completion time for the job is currently not known.
152
160
153
-
-Job 60 is an `add index` job, which is currently queued waiting for job 59 to complete. When job 59 completes, the `STATE`of job 60 will switch to `running`.
161
+
-The `STATE` for `job_id` 566 is shown as `queueing`, indicating that it is queuing. When job 565 completes and job 566 begins execution, the `STATE`for job 566 will change to `running`.
154
162
155
163
- For destructive changes such as dropping an index or dropping a table, the `SCHEMA_STATE` will change to `none` when the job is complete. For additive changes, the `SCHEMA_STATE` will change to `public`.
0 commit comments