Skip to content

Commit 92b41a0

Browse files
authored
tikv: update auto compaction config (pingcap#20708) (pingcap#20886)
1 parent 029f0d9 commit 92b41a0

File tree

3 files changed

+76
-5
lines changed

3 files changed

+76
-5
lines changed

dynamic-config.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,6 @@ show warnings;
130130
| raftstore.max-apply-unpersisted-log-limit | 允许 apply 已 commit 但尚未持久化的 Raft 日志的最大数量 |
131131
| raftstore.split-region-check-tick-interval | 检查 Region 是否需要分裂的时间间隔 |
132132
| raftstore.region-split-check-diff | 允许 Region 数据超过指定大小的最大值 |
133-
| raftstore.region-compact-check-interval | 检查是否需要人工触发 RocksDB compaction 的时间间隔 |
134-
| raftstore.region-compact-check-step | 每轮校验人工 compaction 时,一次性检查的 Region 个数 |
135-
| raftstore.region-compact-min-tombstones | 触发 RocksDB compaction 需要的 tombstone 个数 |
136-
| raftstore.region-compact-tombstones-percent | 触发 RocksDB compaction 需要的 tombstone 所占比例 |
137133
| raftstore.pd-heartbeat-tick-interval | 触发 Region 对 PD 心跳的时间间隔 |
138134
| raftstore.pd-store-heartbeat-tick-interval | 触发 store 对 PD 心跳的时间间隔 |
139135
| raftstore.snap-mgr-gc-tick-interval | 触发回收过期 snapshot 文件的时间间隔 |
@@ -184,6 +180,12 @@ show warnings;
184180
| gc.max-write-bytes-per-sec | 一秒可写入 RocksDB 的最大字节数 |
185181
| gc.enable-compaction-filter | 是否使用 compaction filter |
186182
| gc.compaction-filter-skip-version-check | 是否跳过 compaction filter 的集群版本检查(未 release)|
183+
| gc.auto-compaction.check-interval | TiKV 检查是否需要触发自动 RocksDB compaction 的时间间隔 |
184+
| gc.auto-compaction.tombstone-num-threshold | 触发 TiKV 自动 (RocksDB) compaction 需要的 RocksDB tombstone 个数 |
185+
| gc.auto-compaction.tombstone-percent-threshold | 触发 TiKV 自动 (RocksDB) compaction 需要的 RocksDB tombstone 所占比例 |
186+
| gc.auto-compaction.redundant-rows-threshold | 触发 TiKV 自动 (RocksDB) compaction 需要的冗余的 MVCC 数据行数 |
187+
| gc.auto-compaction.redundant-rows-percent-threshold | 触发 TiKV 自动 (RocksDB) compaction 需要的冗余的 MVCC 数据行数所占比例 |
188+
| gc.auto-compaction.bottommost-level-force | 控制是否强制对 RocksDB 最底层文件进行 compaction |
187189
| {db-name}.max-total-wal-size | WAL 总大小限制 |
188190
| {db-name}.max-background-jobs | RocksDB 后台线程个数 |
189191
| {db-name}.max-background-flushes | RocksDB flush 线程个数 |

garbage-collection-configuration.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,5 @@ show config where type = 'tikv' and name like '%enable-compaction-filter%';
9191
> 在使用 Compaction Filter 机制时,可能会出现 GC 进度延迟的情况,从而影响 TiKV 扫描性能。当你的负载中含有大量 coprocessor 请求,并且在 [**TiKV-Details > Coprocessor Detail**](/grafana-tikv-dashboard.md#coprocessor-detail) 面板中发现 Total Ops Details 的 `next()``prev()` 调用次数远远超过 `processed_keys` 调用的三倍时,可以采取以下措施:
9292
>
9393
> - 对于 TiDB v7.1.3 之前版本,建议尝试关闭 Compaction Filter,以加快 GC 速度。
94-
> - 从 v7.1.3 开始,TiDB 会根据每个 Region 的冗余版本数量 [`region-compact-min-redundant-rows`](/tikv-configuration-file.md#region-compact-min-redundant-rows-从-v710-版本开始引入) 和比例 [`region-compact-redundant-rows-percent`](/tikv-configuration-file.md#region-compact-redundant-rows-percent-从-v710-版本开始引入) 自动触发 compaction,从而提高 Compaction Filter 的 GC 速度。因此,在 v7.1.3 及之后的版本中,如果遇到上述情况,建议调整这两个参数,无需关闭 Compaction Filter。
94+
> - 在 TiDB v7.1.3 到 v7.5.6 及其之间的版本中,TiDB 会根据每个 Region 的冗余版本数量 [`region-compact-min-redundant-rows`](/tikv-configuration-file.md#region-compact-min-redundant-rows-从-v710-版本开始引入) 和比例 [`region-compact-redundant-rows-percent`](/tikv-configuration-file.md#region-compact-redundant-rows-percent-从-v710-版本开始引入) 自动触发 compaction,从而提高 Compaction Filter 的 GC 速度。如果遇到上述情况,建议调整这两个参数,无需关闭 Compaction Filter。
95+
> - 从 TiDB v7.5.7 开始,[`region-compact-min-redundant-rows`](/tikv-configuration-file.md#region-compact-min-redundant-rows-从-v710-版本开始引入)[`region-compact-redundant-rows-percent`](/tikv-configuration-file.md#region-compact-redundant-rows-percent-从-v710-版本开始引入) 已废弃,TiDB 会根据 [`gc.auto-compaction.redundant-rows-threshold`](/tikv-configuration-file.md#redundant-rows-threshold-从-v757-版本开始引入)[`gc.auto-compaction.redundant-rows-percent-threshold`](/tikv-configuration-file.md#redundant-rows-percent-threshold-从-v757-版本开始引入) 自动触发 compaction。如果遇到上述情况,建议调整这两个参数,无需关闭 Compaction Filter。

tikv-configuration-file.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,38 +789,62 @@ raftstore 相关的配置项。
789789

790790
### `region-compact-check-interval`
791791

792+
> **警告:**
793+
>
794+
> 从 v7.5.7 开始,该配置项被废弃,其功能由 [`gc.auto-compaction.check-interval`](#check-interval-从-v757-版本开始引入) 代替。
795+
792796
+ 检查是否需要人工触发 RocksDB compaction 的时间间隔,0 表示不启用。
793797
+ 默认值:5m
794798
+ 最小值:0
795799

796800
### `region-compact-check-step`
797801

802+
> **警告:**
803+
>
804+
> 从 v7.5.7 开始,该配置项被废弃。
805+
798806
+ 每轮校验人工 compaction 时,一次性检查的 Region 个数。
799807
+ 默认值:
800808
+`storage.engine="raft-kv"` 时,默认值为 100。
801809
+`storage.engine="partitioned-raft-kv"` 时,默认值为 5。
802810

803811
### `region-compact-min-tombstones`
804812

813+
> **警告:**
814+
>
815+
> 从 v7.5.7 开始,该配置项被废弃,其功能由 [`gc.auto-compaction.tombstone-num-threshold`](#tombstone-num-threshold-从-v757-版本开始引入) 代替。
816+
805817
+ 触发 RocksDB compaction 需要的 tombstone 个数。
806818
+ 默认值:10000
807819
+ 最小值:0
808820

809821
### `region-compact-tombstones-percent`
810822

823+
> **警告:**
824+
>
825+
> 从 v7.5.7 开始,该配置项被废弃,其功能由 [`gc.auto-compaction.tombstone-percent-threshold`](#tombstone-percent-threshold-从-v757-版本开始引入) 代替。
826+
811827
+ 触发 RocksDB compaction 需要的 tombstone 所占比例。
812828
+ 默认值:30
813829
+ 最小值:1
814830
+ 最大值:100
815831

816832
### `region-compact-min-redundant-rows` <span class="version-mark">从 v7.1.0 版本开始引入</span>
817833

834+
> **警告:**
835+
>
836+
> 从 v7.5.7 开始,该配置项被废弃,其功能由 [`gc.auto-compaction.redundant-rows-threshold`](#redundant-rows-threshold-从-v757-版本开始引入) 代替。
837+
818838
+ 触发 RocksDB compaction 需要的冗余的 MVCC 数据行数。
819839
+ 默认值:`50000`
820840
+ 最小值:`0`
821841

822842
### `region-compact-redundant-rows-percent` <span class="version-mark">从 v7.1.0 版本开始引入</span>
823843

844+
> **警告:**
845+
>
846+
> 从 v7.5.7 开始,该配置项被废弃,其功能由 [`gc.auto-compaction.redundant-rows-percent-threshold`](#redundant-rows-percent-threshold-从-v757-版本开始引入) 代替。
847+
824848
+ 触发 RocksDB compaction 需要的冗余的 MVCC 数据行所占比例。
825849
+ 默认值:`20`
826850
+ 最小值:`1`
@@ -2215,6 +2239,50 @@ Raft Engine 相关的配置项。
22152239
+`enable-compaction-filter``false` 时 GC 线程个数。
22162240
+ 默认值:1
22172241

2242+
## gc.auto-compaction
2243+
2244+
用于配置 TiKV 自动 compaction 的行为。
2245+
2246+
### `check-interval` <span class="version-mark">从 v7.5.7 版本开始引入</span>
2247+
2248+
+ TiKV 检查是否需要触发自动 compaction 的时间间隔。在此时间段内,满足自动 compaction 条件的 Region 会按优先级进行处理。当到达此间隔时,TiKV 会重新扫描 Region 信息并重新计算优先级。
2249+
+ 默认值:`"300s"`
2250+
2251+
### `tombstone-num-threshold` <span class="version-mark">从 v7.5.7 版本开始引入</span>
2252+
2253+
+ 触发 TiKV 自动 compaction 需要的 RocksDB tombstone 个数。当 tombstone 数量达到此阈值,或 tombstone 所占比例达到 [`tombstone-percent-threshold`](#tombstone-percent-threshold-从-v757-版本开始引入) 时,TiKV 将触发自动 compaction。
2254+
+ 仅在关闭 [Compaction Filter](/garbage-collection-configuration.md) 时生效。
2255+
+ 默认值:`10000`
2256+
+ 最小值:`0`
2257+
2258+
### `tombstone-percent-threshold` <span class="version-mark">从 v7.5.7 版本开始引入</span>
2259+
2260+
+ 触发 TiKV 自动 compaction 需要的 RocksDB tombstone 所占比例。当 tombstone 所占比例达到此阈值,或 tombstone 数量达到 [`tombstone-num-threshold`](#tombstone-num-threshold-从-v757-版本开始引入) 时,TiKV 将触发自动 compaction。
2261+
+ 仅在关闭 [Compaction Filter](/garbage-collection-configuration.md) 时生效。
2262+
+ 默认值:`30`
2263+
+ 最小值:`0`
2264+
+ 最大值:`100`
2265+
2266+
### `redundant-rows-threshold` <span class="version-mark">从 v7.5.7 版本开始引入</span>
2267+
2268+
+ 触发 TiKV 自动 compaction 需要的冗余的 MVCC 数据行数,包含 RocksDB tombstone、TiKV stale versions 和 TiKV deletion tombstones。当冗余的 MVCC 数据行数达到此阈值,或这些行数的占比达到 [`redundant-rows-percent-threshold`](#redundant-rows-percent-threshold-从-v757-版本开始引入) 时,TiKV 将触发自动 compaction。
2269+
+ 仅在开启 [Compaction Filter](/garbage-collection-configuration.md) 时生效。
2270+
+ 默认值:`50000`
2271+
+ 最小值:`0`
2272+
2273+
### `redundant-rows-percent-threshold` <span class="version-mark">从 v7.5.7 版本开始引入</span>
2274+
2275+
+ 触发 TiKV 自动 compaction 需要的冗余的 MVCC 数据行数所占比例。冗余数据包含 RocksDB tombstone、TiKV stale versions 和 TiKV deletion tombstones。当冗余的 MVCC 数据行数达到 [`redundant-rows-threshold`](#redundant-rows-threshold-从-v757-版本开始引入),或这些行数的占比达到 `redundant-rows-percent-threshold` 时,TiKV 将触发自动 compaction。
2276+
+ 仅在开启 [Compaction Filter](/garbage-collection-configuration.md) 时生效。
2277+
+ 默认值:`20`
2278+
+ 最小值:`0`
2279+
+ 最大值:`100`
2280+
2281+
### `bottommost-level-force` <span class="version-mark">从 v7.5.7 版本开始引入</span>
2282+
2283+
+ 控制是否强制对 RocksDB 最底层文件进行 compaction。
2284+
+ 默认值:`true`
2285+
22182286
## backup
22192287

22202288
用于 BR 备份相关的配置项。

0 commit comments

Comments
 (0)