Skip to content
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

resource_control: support config background tasks resource limit #18945

Merged
merged 8 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dynamic-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ The following TiKV configuration items can be modified dynamically:
| `readpool.unified.max-thread-count` | The maximum number of threads in the thread pool that uniformly processes read requests, which is the size of the UnifyReadPool thread pool |
| `readpool.unified.max-tasks-per-worker` | The maximum number of tasks allowed for a single thread in the unified read pool. `Server Is Busy` error is returned when the value is exceeded. |
| `readpool.unified.auto-adjust-pool-size` | Determines whether to automatically adjust the UnifyReadPool thread pool size |
| `resource-control.priority-ctl-strategy` | Configures the flow control strategy of low-priority tasks. |
| `coprocessor.split-region-on-table` | Enables to split Region by table |
| `coprocessor.batch-split-limit` | The threshold of Region split in batches |
| `coprocessor.region-max-size` | The maximum size of a Region |
Expand Down
17 changes: 9 additions & 8 deletions sql-statements/sql-statement-alter-resource-group.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ResourceGroupOptionList ::=
| ResourceGroupOptionList ',' DirectResourceGroupOption

DirectResourceGroupOption ::=
"RU_PER_SEC" EqOpt stringLit
"RU_PER_SEC" EqOpt LengthNum
| "PRIORITY" EqOpt ResourceGroupPriorityOption
| "BURSTABLE"
| "BURSTABLE" EqOpt Boolean
Expand Down Expand Up @@ -72,6 +72,7 @@ BackgroundOptionList ::=

DirectBackgroundOption ::=
"TASK_TYPES" EqOpt stringLit
| "UTILIZATION_LIMIT" EqOpt LengthNum
```

TiDB supports the following `DirectResourceGroupOption`, where [Request Unit (RU)](/tidb-resource-control.md#what-is-request-unit-ru) is a unified abstraction unit in TiDB for CPU, IO, and other system resources.
Expand All @@ -82,7 +83,7 @@ TiDB supports the following `DirectResourceGroupOption`, where [Request Unit (RU
| `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. |
| `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.md#manage-queries-that-consume-more-resources-than-expected-runaway-queries). |
| `BACKGROUND` | Configure the background tasks. For more details, see [Manage background tasks](/tidb-resource-control.md#manage-background-tasks). | `BACKGROUND=(TASK_TYPES="br,stats")` indicates that the backup and restore and statistics collection related tasks are scheduled as background tasks. |
| `BACKGROUND` | Configure the background tasks. For more details, see [Manage background tasks](/tidb-resource-control.md#manage-background-tasks). | `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. |

> **Note:**
>
Expand Down Expand Up @@ -152,7 +153,7 @@ SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1';
Modify the `BACKGROUND` option for the `default` resource group.

```sql
ALTER RESOURCE GROUP default BACKGROUND = (TASK_TYPES = "br,ddl");
ALTER RESOURCE GROUP default BACKGROUND = (TASK_TYPES = "br,ddl", UTILIZATION_LIMIT=30);
```

```sql
Expand All @@ -164,11 +165,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' |
+---------+------------+----------+-----------+-------------+---------------------+
+---------+------------+----------+-----------+-------------+-------------------------------------------+
| NAME | RU_PER_SEC | PRIORITY | BURSTABLE | QUERY_LIMIT | BACKGROUND |
+---------+------------+----------+-----------+-------------+-------------------------------------------+
| default | UNLIMITED | MEDIUM | YES | NULL | TASK_TYPES='br,ddl', UTILIZATION_LIMIT=30 |
+---------+------------+----------+-----------+-------------+-------------------------------------------+
1 rows in set (1.30 sec)
```

Expand Down
17 changes: 9 additions & 8 deletions tidb-resource-control.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,8 @@ Starting from v7.4.0, the TiDB resource control feature supports managing backgr

#### `BACKGROUND` parameters

`TASK_TYPES`: specifies the task types that need to be managed as background tasks. Use commas (`,`) to separate multiple task types.
- `TASK_TYPES`: specifies the task types that need to be managed as background tasks. Use commas (`,`) to separate multiple task types.
- `UTILIZATION_LIMIT`: limits the maximum percentage (0-100) of resources that background tasks can consume on each TiKV node. By default, TiKV calculates the available resources for background tasks based on the total resources of the node and the resources currently occupied by the foreground tasks. If `UTILIZATION_LIMIT` is configured, the resource allocated to background tasks will not exceed this limit.

TiDB supports the following types of background tasks:

Expand Down Expand Up @@ -444,10 +445,10 @@ By default, the task types that are marked as background tasks are `""`, and the

#### Examples

1. Modify the `default` resource group and mark `br` and `ddl` as background tasks.
1. Modify the `default` resource group by marking `br` and `ddl` as background tasks and setting the resource limit of background tasks to 30%.

```sql
ALTER RESOURCE GROUP `default` BACKGROUND=(TASK_TYPES='br,ddl');
ALTER RESOURCE GROUP `default` BACKGROUND=(TASK_TYPES='br,ddl', UTILIZATION_LIMIT=30);
```

2. Change the `default` resource group to revert the background task type to its default value.
Expand All @@ -471,11 +472,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' |
+---------+------------+----------+-----------+-------------+---------------------+
+---------+------------+----------+-----------+-------------+-------------------------------------------+
| NAME | RU_PER_SEC | PRIORITY | BURSTABLE | QUERY_LIMIT | BACKGROUND |
+---------+------------+----------+-----------+-------------+-------------------------------------------+
| default | UNLIMITED | MEDIUM | YES | 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:
Expand Down
12 changes: 11 additions & 1 deletion tikv-configuration-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -1990,7 +1990,7 @@ Configuration items related to Raft Engine.
> 3. Enable Raft Engine by setting `enable` to `true` and restart TiKV to make the configuration take effect.

+ Specifies the version of log files in Raft Engine.
+ Value Options:
+ Value options:
+ `1`: Default log file version for TiKV earlier than v6.3.0. Can be read by TiKV >= v6.1.0.
+ `2`: Supports log recycling. Can be read by TiKV >= v6.3.0.
+ Default value:
Expand Down Expand Up @@ -2426,6 +2426,16 @@ Configuration items related to resource control of the TiKV storage layer.
+ Enabling this configuration item only works when [`tidb_enable_resource_control](/system-variables.md#tidb_enable_resource_control-new-in-v660) is enabled on TiDB. When this configuration item is enabled, TiKV will use the priority queue to schedule the queued read/write requests from foreground users. The scheduling priority of a request is inversely related to the amount of resources already consumed by the resource group that receives this request, and positively related to the quota of the corresponding resource group.
+ Default value: `true`, which means scheduling based on the RU of the resource group is enabled.

### `priority-ctl-strategy` <span class="version-mark">New in v8.4.0</span>

Specifies the flow control strategy for low-priority tasks. TiKV ensures that higher priority tasks are prioritized for execution by applying flow control to low-priority tasks.

+ Value options:
+ `aggressive`: this policy prioritizes the performance of high-priority tasks, ensuring that the throughput and latency of high-priority tasks are largely unaffected, but low-priority tasks will run slower.
+ `moderate`: this policy imposes a balanced flow control on low-priority tasks and has a lower impact on high-priority tasks.
+ `conservative`: this policy prioritizes ensuring that system resources are fully utilized, allowing low-priority tasks to fully utilize system available resources as needed, and therefore has a greater performance impact on high-priority tasks.
+ Default value: `moderate`.

## split

Configuration items related to [Load Base Split](/configure-load-base-split.md).
Expand Down
Loading