diff --git a/information-schema/information-schema-resource-groups.md b/information-schema/information-schema-resource-groups.md index 0da7bb84235d6..99da4124d998f 100644 --- a/information-schema/information-schema-resource-groups.md +++ b/information-schema/information-schema-resource-groups.md @@ -17,15 +17,17 @@ DESC resource_groups; ``` ```sql -+------------+-------------+------+------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+------------+-------------+------+------+---------+-------+ -| NAME | varchar(32) | NO | | NULL | | -| RU_PER_SEC | bigint(21) | YES | | NULL | | -| PRIORITY | varchar(6) | YES | | NULL | | -| BURSTABLE | varchar(3) | YES | | NULL | | -+------------+-------------+------+------+---------+-------+ -3 rows in set (0.00 sec) ++-------------+--------------+------+------+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++-------------+--------------+------+------+---------+-------+ +| NAME | varchar(32) | NO | | NULL | | +| RU_PER_SEC | varchar(21) | YES | | NULL | | +| PRIORITY | varchar(6) | YES | | NULL | | +| BURSTABLE | varchar(3) | YES | | NULL | | +| QUERY_LIMIT | varchar(256) | YES | | NULL | | +| BACKGROUND | varchar(256) | YES | | NULL | | ++-------------+--------------+------+------+---------+-------+ +6 rows in set (0.00 sec) ``` ## Examples @@ -35,11 +37,11 @@ SELECT * FROM information_schema.resource_groups; -- View all resource groups. T ``` ```sql -+---------+------------+----------+-----------+ -| NAME | RU_PER_SEC | PRIORITY | BURSTABLE | -+---------+------------+----------+-----------+ -| default | UNLIMITED | MEDIUM | YES | -+---------+------------+----------+-----------+ ++---------+------------+----------+----------------+-------------+------------+ +| NAME | RU_PER_SEC | PRIORITY | BURSTABLE | QUERY_LIMIT | BACKGROUND | ++---------+------------+----------+----------------+-------------+------------+ +| default | UNLIMITED | MEDIUM | YES(UNLIMITED) | NULL | NULL | ++---------+------------+----------+----------------+-------------+------------+ ``` ```sql @@ -68,11 +70,11 @@ SELECT * FROM information_schema.resource_groups WHERE NAME = 'rg1'; -- View the ``` ```sql -+------+------------+----------+-----------+-------------+ -| NAME | RU_PER_SEC | PRIORITY | BURSTABLE | QUERY_LIMIT | -+------+------------+----------+-----------+-------------+ -| rg1 | 1000 | MEDIUM | NO | NULL | -+------+------------+----------+-----------+-------------+ ++------+------------+----------+-----------+-------------+------------+ +| NAME | RU_PER_SEC | PRIORITY | BURSTABLE | QUERY_LIMIT | BACKGROUND | ++------+------------+----------+-----------+-------------+------------+ +| rg1 | 1000 | MEDIUM | NO | NULL | NULL | ++------+------------+----------+-----------+-------------+------------+ 1 row in set (0.00 sec) ``` @@ -81,8 +83,8 @@ The descriptions of the columns in the `RESOURCE_GROUPS` table are as follows: * `NAME`: the name of the resource group. * `RU_PER_SEC`: the backfilling speed of the resource group. The unit is RU/second, in which RU means [Request Unit](/tidb-resource-control-ru-groups.md#what-is-request-unit-ru). * `PRIORITY`: the absolute priority of tasks to be processed on TiKV. Different resources are scheduled according to the `PRIORITY` setting. Tasks with high `PRIORITY` are scheduled first. For resource groups with the same `PRIORITY`, tasks will be scheduled proportionally according to the `RU_PER_SEC` configuration. If `PRIORITY` is not specified, the default priority is `MEDIUM`. -* `BURSTABLE`: whether to allow the resource group to overuse the available system resources. +* `BURSTABLE`: whether to allow the resource group to overuse the available system resources. There are three modes, `OFF`, which means this resource group is not allowed to overuse the remaining system resources; `MODERATED`, which means this resource group is allowed to overuse the remaining system resources in a limited way; and `UNLIMITED`, which means this resource group is allowed to overuse the remaining system resources in an unlimited way. If no target value is specified for `BURSTABLE`, `MODERATED` is enabled by default. > **Note:** > -> TiDB automatically creates a `default` resource group during cluster initialization. For this resource group, the default value of `RU_PER_SEC` is `UNLIMITED` (equivalent to the maximum value of the `INT` type, that is, `2147483647`) and it is in `BURSTABLE` mode. All requests that are not bound to any resource group are automatically bound to this `default` resource group. When you create a new configuration for another resource group, it is recommended to modify the `default` resource group configuration as needed. +> TiDB automatically creates a `default` resource group during cluster initialization. For this resource group, the default value of `RU_PER_SEC` is `UNLIMITED` (equivalent to the maximum value of the `INT` type, that is, `2147483647`) and its `BURSTABLE` mode is `UNLIMITED`. All requests that are not bound to any resource group are automatically bound to this `default` resource group. When you create a new configuration for another resource group, it is recommended to modify the `default` resource group configuration as needed. diff --git a/sql-statements/sql-statement-alter-resource-group.md b/sql-statements/sql-statement-alter-resource-group.md index 005cd9e6b1c24..ed84944e312e3 100644 --- a/sql-statements/sql-statement-alter-resource-group.md +++ b/sql-statements/sql-statement-alter-resource-group.md @@ -33,7 +33,9 @@ DirectResourceGroupOption ::= "RU_PER_SEC" EqOpt LengthNum | "PRIORITY" EqOpt ResourceGroupPriorityOption | "BURSTABLE" -| "BURSTABLE" EqOpt Boolean +| "BURSTABLE" EqOpt "MODERATED" +| "BURSTABLE" EqOpt "UNLIMITED" +| "BURSTABLE" EqOpt "OFF" | "QUERY_LIMIT" EqOpt '(' ResourceGroupRunawayOptionList ')' | "QUERY_LIMIT" EqOpt '(' ')' | "QUERY_LIMIT" EqOpt "NULL" @@ -84,7 +86,7 @@ TiDB supports the following `DirectResourceGroupOption`, where [Request Unit (RU |---------------|-------------------------------------|------------------------| | `RU_PER_SEC` | Rate of RU backfilling per second | `RU_PER_SEC = 500` indicates that this resource group is backfilled with 500 RUs per second | | `PRIORITY` | The absolute priority of tasks to be processed on TiKV | `PRIORITY = HIGH` indicates that the priority is high. If not specified, the default value is `MEDIUM`. | -| `BURSTABLE` | If the `BURSTABLE` attribute is set, TiDB allows the corresponding resource group to use the available system resources when the quota is exceeded. | +| `BURSTABLE` | TiDB allows the corresponding resource group to use the available system resources when the quota is exceeded. There are three modes, `OFF`, which means this resource group is not allowed to overuse the remaining system resources; `MODERATED`, which means this resource group is allowed to overuse the remaining system resources in a limited way; and `UNLIMITED`, which means this resource group is allowed to overuse the remaining system resources in an unlimited way. If no target value is specified for `BURSTABLE`, `MODERATED` is enabled by default. | | `QUERY_LIMIT` | When the query execution meets this condition, the query is identified as a runaway query and the corresponding action is executed. | `QUERY_LIMIT=(EXEC_ELAPSED='60s', ACTION=KILL, WATCH=EXACT DURATION='10m')` indicates that the query is identified as a runaway query when the execution time exceeds 60 seconds. The query is terminated. All SQL statements with the same SQL text will be terminated immediately in the coming 10 minutes. `QUERY_LIMIT=()` or `QUERY_LIMIT=NULL` means that runaway control is not enabled. See [Runaway Queries](/tidb-resource-control-runaway-queries.md). | | `BACKGROUND` | Configure the background tasks. For more details, see [Manage background tasks](/tidb-resource-control-background-tasks.md). | `BACKGROUND=(TASK_TYPES="br,stats", UTILIZATION_LIMIT=30)` indicates that the backup and restore and statistics collection related tasks are scheduled as background tasks, and background tasks can consume 30% of the TiKV resources at most. | @@ -168,11 +170,11 @@ SELECT * FROM information_schema.resource_groups WHERE NAME ='default'; ``` ```sql -+---------+------------+----------+-----------+-------------+-------------------------------------------+ -| NAME | RU_PER_SEC | PRIORITY | BURSTABLE | QUERY_LIMIT | BACKGROUND | -+---------+------------+----------+-----------+-------------+-------------------------------------------+ -| default | UNLIMITED | MEDIUM | YES | NULL | TASK_TYPES='br,ddl', UTILIZATION_LIMIT=30 | -+---------+------------+----------+-----------+-------------+-------------------------------------------+ ++---------+------------+----------+----------------------+-------------+-------------------------------------------+ +| NAME | RU_PER_SEC | PRIORITY | BURSTABLE | QUERY_LIMIT | BACKGROUND | ++---------+------------+----------+----------------------+-------------+-------------------------------------------+ +| default | UNLIMITED | MEDIUM | YES(UNLIMITED) | NULL | TASK_TYPES='br,ddl', UTILIZATION_LIMIT=30 | ++---------+------------+----------+----------------------+-------------+-------------------------------------------+ 1 rows in set (1.30 sec) ``` diff --git a/sql-statements/sql-statement-create-resource-group.md b/sql-statements/sql-statement-create-resource-group.md index 2916f30989c60..0ddfecd5f500b 100644 --- a/sql-statements/sql-statement-create-resource-group.md +++ b/sql-statements/sql-statement-create-resource-group.md @@ -33,7 +33,9 @@ DirectResourceGroupOption ::= "RU_PER_SEC" EqOpt stringLit | "PRIORITY" EqOpt ResourceGroupPriorityOption | "BURSTABLE" -| "BURSTABLE" EqOpt Boolean +| "BURSTABLE" EqOpt "MODERATED" +| "BURSTABLE" EqOpt "UNLIMITED" +| "BURSTABLE" EqOpt "OFF" | "QUERY_LIMIT" EqOpt '(' ResourceGroupRunawayOptionList ')' | "QUERY_LIMIT" EqOpt '(' ')' | "QUERY_LIMIT" EqOpt "NULL" @@ -81,13 +83,13 @@ TiDB supports the following `DirectResourceGroupOption`, where [Request Unit (RU |---------------|-------------------------------------|------------------------| | `RU_PER_SEC` | Rate of RU backfilling per second | `RU_PER_SEC = 500` indicates that this resource group is backfilled with 500 RUs per second | | `PRIORITY` | The absolute priority of tasks to be processed on TiKV | `PRIORITY = HIGH` indicates that the priority is high. If not specified, the default value is `MEDIUM`. | -| `BURSTABLE` | If the `BURSTABLE` attribute is set, TiDB allows the corresponding resource group to use the available system resources when the quota is exceeded. | +| `BURSTABLE` | TiDB allows the corresponding resource group to use the available system resources when the quota is exceeded. There are three modes, `OFF`, which means this resource group is not allowed to overuse the remaining system resources; `MODERATED`, which means this resource group is allowed to overuse the remaining system resources in a limited way; and `UNLIMITED`, which means this resource group is allowed to overuse the remaining system resources in an unlimited way. If no target value is specified for `BURSTABLE`, `MODERATED` is enabled by default. | | `QUERY_LIMIT` | When the query execution meets this condition, the query is identified as a runaway query and the corresponding action is executed. | `QUERY_LIMIT=(EXEC_ELAPSED='60s', ACTION=KILL, WATCH=EXACT DURATION='10m')` indicates that the query is identified as a runaway query when the execution time exceeds 60 seconds. The query is terminated. All SQL statements with the same SQL text will be terminated immediately in the coming 10 minutes. `QUERY_LIMIT=()` or `QUERY_LIMIT=NULL` means that runaway control is not enabled. See [Runaway Queries](/tidb-resource-control-runaway-queries.md). | > **Note:** > > - The `CREATE RESOURCE GROUP` statement can only be executed when the global variable [`tidb_enable_resource_control`](/system-variables.md#tidb_enable_resource_control-new-in-v660) is set to `ON`. -> TiDB automatically creates a `default` resource group during cluster initialization. For this resource group, the default value of `RU_PER_SEC` is `UNLIMITED` (equivalent to the maximum value of the `INT` type, that is, `2147483647`) and it is in `BURSTABLE` mode. All requests that are not bound to any resource group are automatically bound to this `default` resource group. When you create a new configuration for another resource group, it is recommended to modify the `default` resource group configuration as needed. +> TiDB automatically creates a `default` resource group during cluster initialization. For this resource group, the default value of `RU_PER_SEC` is `UNLIMITED` (equivalent to the maximum value of the `INT` type, that is, `2147483647`) and its `BURSTABLE` mode is `UNLIMTED`. All requests that are not bound to any resource group are automatically bound to this `default` resource group. When you create a new configuration for another resource group, it is recommended to modify the `default` resource group configuration as needed. > - Currently, only the `default` resource group supports modifying the `BACKGROUND` configuration. ## Examples @@ -127,12 +129,12 @@ SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1' or NAME = 'rg ``` ```sql -+------+------------+----------+-----------+---------------------------------+ -| NAME | RU_PER_SEC | PRIORITY | BURSTABLE | QUERY_LIMIT | -+------+------------+----------+-----------+---------------------------------+ -| rg1 | 100 | HIGH | YES | NULL | -| rg2 | 200 | MEDIUM | NO | EXEC_ELAPSED=100ms, ACTION=KILL | -+------+------------+----------+-----------+---------------------------------+ ++------+------------+----------+----------------------+---------------------------------+ +| NAME | RU_PER_SEC | PRIORITY | BURSTABLE | QUERY_LIMIT | ++------+------------+----------+----------------------+---------------------------------+ +| rg1 | 100 | HIGH | YES(MODERATED) | NULL | +| rg2 | 200 | MEDIUM | NO | EXEC_ELAPSED=100ms, ACTION=KILL | ++------+------------+----------+----------------------+---------------------------------+ 2 rows in set (1.30 sec) ``` diff --git a/sql-statements/sql-statement-drop-resource-group.md b/sql-statements/sql-statement-drop-resource-group.md index eb1df28582c01..c34559da209d7 100644 --- a/sql-statements/sql-statement-drop-resource-group.md +++ b/sql-statements/sql-statement-drop-resource-group.md @@ -55,11 +55,11 @@ SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1'; ``` ```sql -+------+------------+----------+-----------+-------------+ -| NAME | RU_PER_SEC | PRIORITY | BURSTABLE | QUERY_LIMIT | -+------+------------+----------+-----------+-------------+ -| rg1 | 500 | MEDIUM | YES | NULL | -+------+------------+----------+-----------+-------------+ ++------+------------+----------+----------------------+-------------+ +| NAME | RU_PER_SEC | PRIORITY | BURSTABLE | QUERY_LIMIT | ++------+------------+----------+----------------------+-------------+ +| rg1 | 500 | MEDIUM | YES(MODERATED) | NULL | ++------+------------+----------+----------------------+-------------+ 1 row in set (0.01 sec) ``` diff --git a/tidb-resource-control-background-tasks.md b/tidb-resource-control-background-tasks.md index 537e010a8b48a..8bef9ca92c698 100644 --- a/tidb-resource-control-background-tasks.md +++ b/tidb-resource-control-background-tasks.md @@ -77,11 +77,11 @@ By default, the task types that are marked as background tasks are `""`, and the The output is as follows: ``` - +---------+------------+----------+-----------+-------------+-------------------------------------------+ - | NAME | RU_PER_SEC | PRIORITY | BURSTABLE | QUERY_LIMIT | BACKGROUND | - +---------+------------+----------+-----------+-------------+-------------------------------------------+ - | default | UNLIMITED | MEDIUM | YES | NULL | TASK_TYPES='br,ddl', UTILIZATION_LIMIT=30 | - +---------+------------+----------+-----------+-------------+-------------------------------------------+ + +---------+------------+----------+----------------------+-------------+-------------------------------------------+ + | NAME | RU_PER_SEC | PRIORITY | BURSTABLE | QUERY_LIMIT | BACKGROUND | + +---------+------------+----------+----------------------+-------------+-------------------------------------------+ + | default | UNLIMITED | MEDIUM | YES(UNLIMITED) | NULL | TASK_TYPES='br,ddl', UTILIZATION_LIMIT=30 | + +---------+------------+----------+----------------------+-------------+-------------------------------------------+ ``` 5. To explicitly mark tasks in the current session as the background type, you can use `tidb_request_source_type` to explicitly specify the task type. The following is an example: diff --git a/tidb-resource-control-ru-groups.md b/tidb-resource-control-ru-groups.md index 3fdd338db65bd..1f7ce7cd47495 100644 --- a/tidb-resource-control-ru-groups.md +++ b/tidb-resource-control-ru-groups.md @@ -185,7 +185,7 @@ You can delete a resource group by using [`DROP RESOURCE GROUP`](/sql-statements The following is an example of how to create a resource group. -1. Create a resource group `rg1`. The resource limit is 500 RUs per second and allows applications in this resource group to overrun resources. +1. Create a resource group `rg1`. The resource limit is 500 RUs per second and allows applications in this resource group to overrun resources. If not specified, its `BURSTABLE` mode is `MODERATED`. ```sql CREATE RESOURCE GROUP IF NOT EXISTS rg1 RU_PER_SEC = 500 BURSTABLE; @@ -203,6 +203,12 @@ The following is an example of how to create a resource group. CREATE RESOURCE GROUP IF NOT EXISTS rg3 RU_PER_SEC = 100 PRIORITY = HIGH; ``` +4. Create a resource group `rg4`. The resource limit is 500 RUs per second and allows applications in this resource group to overrun resources with `UNLIMITED` mode. + + ```sql + CREATE RESOURCE GROUP IF NOT EXISTS rg4 RU_PER_SEC = 500 BURSTABLE=UNLIMITED; + ``` + ### Bind resource groups TiDB supports three levels of resource group settings as follows. @@ -232,7 +238,7 @@ If there are too many requests that result in insufficient resources for the res > **Note:** > > - When you bind a user to a resource group by using `CREATE USER` or `ALTER USER`, it will not take effect for the user's existing sessions, but only for the user's new sessions. -> - TiDB automatically creates a `default` resource group during cluster initialization. For this resource group, the default value of `RU_PER_SEC` is `UNLIMITED` (equivalent to the maximum value of the `INT` type, that is, `2147483647`) and it is in `BURSTABLE` mode. Statements that are not bound to a resource group are automatically bound to this resource group. This resource group does not support deletion, but you can modify the configuration of its RU. +> - TiDB automatically creates a `default` resource group during cluster initialization. For this resource group, the default value of `RU_PER_SEC` is `UNLIMITED` (equivalent to the maximum value of the `INT` type, that is, `2147483647`) and its `BURSTABLE` is `UNLIMITED` mode. Statements that are not bound to a resource group are automatically bound to this resource group. This resource group does not support deletion, but you can modify the configuration of its RU. To unbind users from a resource group, you can simply bind them to the `default` group again as follows: