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

variable: tidb_pipelined_dml_resource_policy #19994

Merged
merged 12 commits into from
Apr 14, 2025
4 changes: 4 additions & 0 deletions pipelined-dml.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ SELECT @@tidb_last_txn_info;
## 相关配置

- 系统变量 [`tidb_dml_type`](/system-variables.md#tidb_dml_type-从-v800-版本开始引入) 用于控制是否在会话级别启用 Pipelined DML。
- 系统变量 [`tidb_pipelined_dml_resource_policy`](/system-variables.md#tidb_pipelined_dml_resource_policy-从-v900-版本开始引入) 用于控制 Pipelined DML 的资源使用策略。当出现以下资源竞争情况时,可以考虑将其调整为 `conservative` 来降低 Pipelined DML 对集群性能的影响:
- TiKV 节点出现写入热点,TiKV 负载过高
- OLTP 业务的请求延迟显著上升
- 集群写入吞吐量明显下降
- 当 [`tidb_dml_type`](/system-variables.md#tidb_dml_type-从-v800-版本开始引入) 设置为 `"bulk"` 时,配置项 [`pessimistic-auto-commit`](/tidb-configuration-file.md#pessimistic-auto-commit) 的效果等同于设置为 `false`。
- 以 Pipelined DML 方式执行事务时,事务的大小不受 TiDB 配置项 [`txn-total-size-limit`](/tidb-configuration-file.md#txn-total-size-limit) 的限制。
- 以 Pipelined DML 方式执行超大事务时,事务耗时可能较长。对于这种模式的事务,其事务锁的最大 TTL 为 [`max-txn-ttl`](/tidb-configuration-file.md#max-txn-ttl) 与 24 小时中的较大值。
Expand Down
16 changes: 16 additions & 0 deletions system-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -4229,6 +4229,22 @@ SHOW WARNINGS;
> - 该选项目前仅对需要上锁单个 key 的语句有效。如果一个语句需要对多行同时上锁,则该选项不会对此类语句生效。
> - 该功能从 v6.6.0 版本引入。在 v6.6.0 版本中,该功能由变量 [`tidb_pessimistic_txn_aggressive_locking`](https://docs.pingcap.com/zh/tidb/v6.6/system-variables#tidb_pessimistic_txn_aggressive_locking-%E4%BB%8E-v660-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5) 控制,默认关闭。

### `tidb_pipelined_dml_resource_policy` <span class="version-mark">从 v9.0.0 版本开始引入</span>

- 作用域:SESSION | GLOBAL
- 是否持久化到集群:是
- 是否受 Hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value) 控制:是
- 类型:字符串型
- 默认值:`"standard"`
- 可选值:`"standard"`、`"conservative"`、`"custom{...}"`
- 该变量控制 [Pipelined DML](/pipelined-dml.md) 的资源使用策略,仅在 [`tidb_dml_type`](#tidb_dml_type-从-v800-版本开始引入) 为 `bulk` 时生效。可选值含义如下:
- `"standard"`:默认的资源使用策略。
- `"conservative"`:Pipelined DML 使用更少的资源,但执行速度更慢,适用于对资源使用较敏感的场景。
- `"custom{option1=value1,option2=value2,...}"` 格式:自定义资源使用策略。可以只指定需要的子项。例如 `"custom{concurrency=8,write_throttle_ratio=0.5}"`。注意需要用双引号包括该值。支持的自定义项包括:
- `concurrency`:flush 操作的并发度,影响 Pipelined DML 的执行速度和资源使用。取值范围为`[1,8192]`。
- `resolve_concurrency`:异步 resolve lock 操作的并发度。只影响 Pipelined DML 资源使用,不影响 Pipelined DML 执行速度。取值范围为`[1,8192]`。
- `write_throttle_ratio`:主动限流(throttle)的时间比例。值越大表示 throttle 时间在总时间中的占比越高,从而减少资源使用。0 表示不进行限流。取值范围为 `[0,1)`。

### `tidb_placement_mode` <span class="version-mark">从 v6.0.0 版本开始引入</span>

- 作用域:SESSION | GLOBAL
Expand Down