From 15c50adf5137f65d721ec9eb4f16fa79c18230e5 Mon Sep 17 00:00:00 2001 From: Ran Date: Thu, 13 Feb 2020 15:50:30 +0800 Subject: [PATCH 1/8] reference: update sql admin syntax --- dev/reference/sql/statements/admin.md | 124 +++++++++++++++++++++----- 1 file changed, 101 insertions(+), 23 deletions(-) diff --git a/dev/reference/sql/statements/admin.md b/dev/reference/sql/statements/admin.md index 2e67fd13bedd0..be982def5bd2b 100644 --- a/dev/reference/sql/statements/admin.md +++ b/dev/reference/sql/statements/admin.md @@ -8,16 +8,48 @@ category: reference This statement is a TiDB extension syntax, used to view the status of TiDB and check the data of tables in TiDB. +{{< copyable "sql" >}} + +```sql +ADMIN SHOW DDL; +``` + +`ADMIN SHOW DDL`: To view the currently running DDL jobs. + +{{< copyable "sql" >}} + +```sql +ADMIN SHOW DDL JOBS [NUM] [WHERE where_condition]; +``` + +* `NUM`: To view the last `NUM` results in the completed DDL job queue. If not specified, `NUM` is by default 10. +* `WHERE`: To add filter conditions. + +`ADMIN SHOW DDL JOBS`: To view all the results in the current DDL job queue (including tasks that are running and waiting to be run) and the last ten results in the completed DDL job queue. + +{{< copyable "sql" >}} + +```sql +ADMIN SHOW DDL JOB QUERIES job_id [, job_id] ...; +``` + +{{< copyable "sql" >}} + ```sql -ADMIN SHOW DDL -ADMIN SHOW DDL JOBS -ADMIN SHOW DDL JOB QUERIES job_id [, job_id] ... -ADMIN CANCEL DDL JOBS job_id [, job_id] ... -ADMIN CHECK TABLE tbl_name [, tbl_name] ... +ADMIN CANCEL DDL JOBS job_id [, job_id] ...; ``` -- `ADMIN SHOW DDL`: To view the currently running DDL jobs. -- `ADMIN SHOW DDL JOBS`: To view all the results in the current DDL job queue (including tasks that are running and waiting to be run) and the last ten results in the completed DDL job queue. +{{< copyable "sql" >}} + +```sql +ADMIN CHECK TABLE tbl_name [, tbl_name] ...; +``` + +{{< copyable "sql" >}} + +```sql +ADMIN REPAIR TABLE tbl_name CREATE TABLE STATEMENT; +``` ## Synopsis @@ -27,23 +59,68 @@ ADMIN CHECK TABLE tbl_name [, tbl_name] ... ## Examples +Run the command below to view the last 10 completed DDL jobs in the currently running DDL job queue. When `NUM` is not specified, only the last 10 completed DDL jobs is presented by default. + +{{< copyable "sql" >}} + +```sql +admin show ddl jobs; +``` + +``` ++--------+---------+------------+---------------------+----------------+-----------+----------+-----------+-----------------------------------+-----------------------------------+---------------+ +| JOB_ID | DB_NAME | TABLE_NAME | JOB_TYPE | SCHEMA_STATE | SCHEMA_ID | TABLE_ID | ROW_COUNT | START_TIME | END_TIME | STATE | ++--------+---------+------------+---------------------+----------------+-----------+----------+-----------+-----------------------------------+-----------------------------------+---------------+ +| 45 | test | t1 | add index | write reorganization | 32 | 37 | 0 | 2019-01-10 12:38:36.501 +0800 CST | | running | +| 44 | test | t1 | add index | none | 32 | 37 | 0 | 2019-01-10 12:36:55.18 +0800 CST | 2019-01-10 12:36:55.852 +0800 CST | rollback done | +| 43 | test | t1 | add index | public | 32 | 37 | 6 | 2019-01-10 12:35:13.66 +0800 CST | 2019-01-10 12:35:14.925 +0800 CST | synced | +| 42 | test | t1 | drop index | none | 32 | 37 | 0 | 2019-01-10 12:34:35.204 +0800 CST | 2019-01-10 12:34:36.958 +0800 CST | synced | +| 41 | test | t1 | add index | public | 32 | 37 | 0 | 2019-01-10 12:33:22.62 +0800 CST | 2019-01-10 12:33:24.625 +0800 CST | synced | +| 40 | test | t1 | drop column | none | 32 | 37 | 0 | 2019-01-10 12:33:08.212 +0800 CST | 2019-01-10 12:33:09.78 +0800 CST | synced | +| 39 | test | t1 | add column | public | 32 | 37 | 0 | 2019-01-10 12:32:55.42 +0800 CST | 2019-01-10 12:32:56.24 +0800 CST | synced | +| 38 | test | t1 | create table | public | 32 | 37 | 0 | 2019-01-10 12:32:41.956 +0800 CST | 2019-01-10 12:32:43.956 +0800 CST | synced | +| 36 | test | | drop table | none | 32 | 34 | 0 | 2019-01-10 11:29:59.982 +0800 CST | 2019-01-10 11:30:00.45 +0800 CST | synced | +| 35 | test | | create table | public | 32 | 34 | 0 | 2019-01-10 11:29:40.741 +0800 CST | 2019-01-10 11:29:41.682 +0800 CST | synced | +| 33 | test | | create schema | public | 32 | 0 | 0 | 2019-01-10 11:29:22.813 +0800 CST | 2019-01-10 11:29:23.954 +0800 CST | synced | ++--------+---------+------------+---------------------+----------------+-----------+----------+-----------+-----------------------------------+-----------------------------------+---------------+ +``` + +Run the command below to view the last 5 completed DDL jobs in the currently running DDL job queue: + +{{< copyable "sql" >}} + ```sql -mysql> admin show ddl jobs; -+--------+---------+------------+---------------+----------------------+-----------+----------+-----------+-----------------------------------+---------------+ -| JOB_ID | DB_NAME | TABLE_NAME | JOB_TYPE | SCHEMA_STATE | SCHEMA_ID | TABLE_ID | ROW_COUNT | START_TIME | STATE | -+--------+---------+------------+---------------+----------------------+-----------+----------+-----------+-----------------------------------+---------------+ -| 45 | test | t1 | add index | write reorganization | 32 | 37 | 0 | 2019-01-10 12:38:36.501 +0800 CST | running | -| 44 | test | t1 | add index | none | 32 | 37 | 0 | 2019-01-10 12:36:55.18 +0800 CST | rollback done | -| 43 | test | t1 | add index | public | 32 | 37 | 6 | 2019-01-10 12:35:13.66 +0800 CST | synced | -| 42 | test | t1 | drop index | none | 32 | 37 | 0 | 2019-01-10 12:34:35.204 +0800 CST | synced | -| 41 | test | t1 | add index | public | 32 | 37 | 0 | 2019-01-10 12:33:22.62 +0800 CST | synced | -| 40 | test | t1 | drop column | none | 32 | 37 | 0 | 2019-01-10 12:33:08.212 +0800 CST | synced | -| 39 | test | t1 | add column | public | 32 | 37 | 0 | 2019-01-10 12:32:55.42 +0800 CST | synced | -| 38 | test | t1 | create table | public | 32 | 37 | 0 | 2019-01-10 12:32:41.956 +0800 CST | synced | -| 36 | test | | drop table | none | 32 | 34 | 0 | 2019-01-10 11:29:59.982 +0800 CST | synced | -| 35 | test | | create table | public | 32 | 34 | 0 | 2019-01-10 11:29:40.741 +0800 CST | synced | -| 33 | test | | create schema | public | 32 | 0 | 0 | 2019-01-10 11:29:22.813 +0800 CST | synced | -+--------+---------+------------+---------------+----------------------+-----------+----------+-----------+-----------------------------------+---------------+ +admin show ddl jobs 5; +``` + +``` ++--------+---------+------------+---------------------+----------------+-----------+----------+-----------+-----------------------------------+-----------------------------------+---------------+ +| JOB_ID | DB_NAME | TABLE_NAME | JOB_TYPE | SCHEMA_STATE | SCHEMA_ID | TABLE_ID | ROW_COUNT | START_TIME | END_TIME | STATE | ++--------+---------+------------+---------------------+----------------+-----------+----------+-----------+-----------------------------------+-----------------------------------+---------------+ +| 45 | test | t1 | add index | write reorganization | 32 | 37 | 0 | 2019-01-10 12:38:36.501 +0800 CST | | running | +| 44 | test | t1 | add index | none | 32 | 37 | 0 | 2019-01-10 12:36:55.18 +0800 CST | 2019-01-10 12:36:55.852 +0800 CST | rollback done | +| 43 | test | t1 | add index | public | 32 | 37 | 6 | 2019-01-10 12:35:13.66 +0800 CST | 2019-01-10 12:35:14.925 +0800 CST | synced | +| 42 | test | t1 | drop index | none | 32 | 37 | 0 | 2019-01-10 12:34:35.204 +0800 CST | 2019-01-10 12:34:36.958 +0800 CST | synced | +| 41 | test | t1 | add index | public | 32 | 37 | 0 | 2019-01-10 12:33:22.62 +0800 CST | 2019-01-10 12:33:24.625 +0800 CST | synced | +| 40 | test | t1 | drop column | none | 32 | 37 | 0 | 2019-01-10 12:33:08.212 +0800 CST | 2019-01-10 12:33:09.78 +0800 CST | synced | ++--------+---------+------------+---------------------+----------------+-----------+----------+-----------+-----------------------------------+-----------------------------------+---------------+ +``` + +Run the command below to view the uncompleted DDL jobs in the test database. The results include the DDL jobs that are running and the last 5 DDL jobs that are completed but failed. + +{{< copyable "sql" >}} + +```sql +admin show ddl jobs 5 where state!='synced' and db_name='test'; +``` + +``` ++--------+---------+------------+---------------------+----------------+-----------+----------+-----------+-----------------------------------+-----------------------------------+---------------+ +| JOB_ID | DB_NAME | TABLE_NAME | JOB_TYPE | SCHEMA_STATE | SCHEMA_ID | TABLE_ID | ROW_COUNT | START_TIME | END_TIME | STATE | ++--------+---------+------------+---------------------+----------------+-----------+----------+-----------+-----------------------------------+-----------------------------------+---------------+ +| 45 | test | t1 | add index | write reorganization | 32 | 37 | 0 | 2019-01-10 12:38:36.501 +0800 CST | | running | +| 44 | test | t1 | add index | none | 32 | 37 | 0 | 2019-01-10 12:36:55.18 +0800 CST | 2019-01-10 12:36:55.852 +0800 CST | rollback done | ++--------+---------+------------+---------------------+----------------+-----------+----------+-----------+-----------------------------------+-----------------------------------+---------------+ ``` * `JOB_ID`: each DDL operation corresponds to one DDL job. `JOB_ID` is globally unique. @@ -58,6 +135,7 @@ mysql> admin show ddl jobs; * `TABLE_ID`: the ID of the table on which the DDL operations are performed. * `ROW_COUNT`: the number of the data rows that have been added when running the `add index` operation. * `START_TIME`: the start time of the DDL operations. +* `END_TIME`: the end time of the DDL operations. * `STATE`: the state of the DDL operations. The common states include: * `none`: it indicates that the operation task has been put in the DDL job queue but has not been performed yet, because it is waiting for the previous tasks to complete. Another reason might be that it becomes the `none` state after running the drop operation, but it will soon be updated to the `synced` state, which means that all TiDB instances have been synced to this state. * `running`: it indicates that the operation is being performed. From ef15969c6421948d48cde1142fa171a4958417fe Mon Sep 17 00:00:00 2001 From: Ran Huang Date: Fri, 14 Feb 2020 16:03:28 +0800 Subject: [PATCH 2/8] Update dev/reference/sql/statements/admin.md Co-Authored-By: Lilian Lee --- dev/reference/sql/statements/admin.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dev/reference/sql/statements/admin.md b/dev/reference/sql/statements/admin.md index be982def5bd2b..233c6faf9114c 100644 --- a/dev/reference/sql/statements/admin.md +++ b/dev/reference/sql/statements/admin.md @@ -8,6 +8,8 @@ category: reference This statement is a TiDB extension syntax, used to view the status of TiDB and check the data of tables in TiDB. +To view the currently running DDL jobs, use `ADMIN SHOW DDL`: + {{< copyable "sql" >}} ```sql From 7e53f3a3fa0d86d3fb4dcb99baa6d270f707d5fe Mon Sep 17 00:00:00 2001 From: Ran Huang Date: Fri, 14 Feb 2020 16:04:44 +0800 Subject: [PATCH 3/8] Update dev/reference/sql/statements/admin.md Co-Authored-By: Lilian Lee --- dev/reference/sql/statements/admin.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/reference/sql/statements/admin.md b/dev/reference/sql/statements/admin.md index 233c6faf9114c..e26aea8128d58 100644 --- a/dev/reference/sql/statements/admin.md +++ b/dev/reference/sql/statements/admin.md @@ -17,7 +17,7 @@ ADMIN SHOW DDL; ``` `ADMIN SHOW DDL`: To view the currently running DDL jobs. - +To view all the results in the current DDL job queue (including tasks that are running and waiting to be run) and the last ten results in the completed DDL job queue, use `ADMIN SHOW DDL JOBS`: {{< copyable "sql" >}} ```sql From 6c1efad0e8b2f657fbd44a58656d225fa649989b Mon Sep 17 00:00:00 2001 From: Ran Huang Date: Fri, 14 Feb 2020 16:05:57 +0800 Subject: [PATCH 4/8] Update dev/reference/sql/statements/admin.md Co-Authored-By: Lilian Lee --- dev/reference/sql/statements/admin.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/reference/sql/statements/admin.md b/dev/reference/sql/statements/admin.md index e26aea8128d58..38c54cac42dda 100644 --- a/dev/reference/sql/statements/admin.md +++ b/dev/reference/sql/statements/admin.md @@ -61,7 +61,7 @@ ADMIN REPAIR TABLE tbl_name CREATE TABLE STATEMENT; ## Examples -Run the command below to view the last 10 completed DDL jobs in the currently running DDL job queue. When `NUM` is not specified, only the last 10 completed DDL jobs is presented by default. +Run the following command to view the last 10 completed DDL jobs in the currently running DDL job queue. When `NUM` is not specified, only the last 10 completed DDL jobs is presented by default. {{< copyable "sql" >}} From daeae5e286033ccc3eb8a82935f4d0ffca3e3291 Mon Sep 17 00:00:00 2001 From: Ran Huang Date: Fri, 14 Feb 2020 16:07:39 +0800 Subject: [PATCH 5/8] Apply suggestions from code review Co-Authored-By: Lilian Lee --- dev/reference/sql/statements/admin.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/reference/sql/statements/admin.md b/dev/reference/sql/statements/admin.md index 38c54cac42dda..df5d22c61f302 100644 --- a/dev/reference/sql/statements/admin.md +++ b/dev/reference/sql/statements/admin.md @@ -87,7 +87,7 @@ admin show ddl jobs; +--------+---------+------------+---------------------+----------------+-----------+----------+-----------+-----------------------------------+-----------------------------------+---------------+ ``` -Run the command below to view the last 5 completed DDL jobs in the currently running DDL job queue: +Run the following command to view the last 5 completed DDL jobs in the currently running DDL job queue: {{< copyable "sql" >}} @@ -108,7 +108,7 @@ admin show ddl jobs 5; +--------+---------+------------+---------------------+----------------+-----------+----------+-----------+-----------------------------------+-----------------------------------+---------------+ ``` -Run the command below to view the uncompleted DDL jobs in the test database. The results include the DDL jobs that are running and the last 5 DDL jobs that are completed but failed. +Run the following command to view the uncompleted DDL jobs in the test database. The results include the DDL jobs that are running and the last 5 DDL jobs that are completed but failed. {{< copyable "sql" >}} From 925cb77c9721b0e290606170ef1b5eedc6b839e8 Mon Sep 17 00:00:00 2001 From: Ran Date: Fri, 14 Feb 2020 16:15:15 +0800 Subject: [PATCH 6/8] Move the command explanation forward --- dev/reference/sql/statements/admin.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/dev/reference/sql/statements/admin.md b/dev/reference/sql/statements/admin.md index df5d22c61f302..d7842347bc7d3 100644 --- a/dev/reference/sql/statements/admin.md +++ b/dev/reference/sql/statements/admin.md @@ -16,7 +16,6 @@ To view the currently running DDL jobs, use `ADMIN SHOW DDL`: ADMIN SHOW DDL; ``` -`ADMIN SHOW DDL`: To view the currently running DDL jobs. To view all the results in the current DDL job queue (including tasks that are running and waiting to be run) and the last ten results in the completed DDL job queue, use `ADMIN SHOW DDL JOBS`: {{< copyable "sql" >}} @@ -27,8 +26,6 @@ ADMIN SHOW DDL JOBS [NUM] [WHERE where_condition]; * `NUM`: To view the last `NUM` results in the completed DDL job queue. If not specified, `NUM` is by default 10. * `WHERE`: To add filter conditions. -`ADMIN SHOW DDL JOBS`: To view all the results in the current DDL job queue (including tasks that are running and waiting to be run) and the last ten results in the completed DDL job queue. - {{< copyable "sql" >}} ```sql From 2fb78cb460839d38cfb06942251f1c47a28623ff Mon Sep 17 00:00:00 2001 From: Ran Date: Mon, 17 Feb 2020 17:50:13 +0800 Subject: [PATCH 7/8] reference: modify capitalization after colons Co-Authored-By: Lilian Lee --- dev/reference/sql/statements/admin.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/reference/sql/statements/admin.md b/dev/reference/sql/statements/admin.md index 794e0ffba2ca8..03a314b6fd0a9 100644 --- a/dev/reference/sql/statements/admin.md +++ b/dev/reference/sql/statements/admin.md @@ -23,8 +23,8 @@ To view all the results in the current DDL job queue (including tasks that are r ADMIN SHOW DDL JOBS [NUM] [WHERE where_condition]; ``` -* `NUM`: To view the last `NUM` results in the completed DDL job queue. If not specified, `NUM` is by default 10. -* `WHERE`: To add filter conditions. +* `NUM`: to view the last `NUM` results in the completed DDL job queue. If not specified, `NUM` is by default 10. +* `WHERE`: to add filter conditions. {{< copyable "sql" >}} From a0aca6fef7bd128d26cc8902ee196d6d49582ca5 Mon Sep 17 00:00:00 2001 From: Ran Date: Mon, 17 Feb 2020 17:51:16 +0800 Subject: [PATCH 8/8] reference: add a new line Co-Authored-By: Lilian Lee --- dev/reference/sql/statements/admin.md | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/reference/sql/statements/admin.md b/dev/reference/sql/statements/admin.md index 03a314b6fd0a9..5526c0b278af7 100644 --- a/dev/reference/sql/statements/admin.md +++ b/dev/reference/sql/statements/admin.md @@ -17,6 +17,7 @@ ADMIN SHOW DDL; ``` To view all the results in the current DDL job queue (including tasks that are running and waiting to be run) and the last ten results in the completed DDL job queue, use `ADMIN SHOW DDL JOBS`: + {{< copyable "sql" >}} ```sql