Skip to content

Commit e3dd815

Browse files
authored
tikv: update auto compaction config (#20708)
1 parent acb1350 commit e3dd815

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
@@ -131,10 +131,6 @@ show warnings;
131131
| raftstore.max-apply-unpersisted-log-limit | 允许 apply 已 commit 但尚未持久化的 Raft 日志的最大数量 |
132132
| raftstore.split-region-check-tick-interval | 检查 Region 是否需要分裂的时间间隔 |
133133
| raftstore.region-split-check-diff | 允许 Region 数据超过指定大小的最大值 |
134-
| raftstore.region-compact-check-interval | 检查是否需要人工触发 RocksDB compaction 的时间间隔 |
135-
| raftstore.region-compact-check-step | 每轮校验人工 compaction 时,一次性检查的 Region 个数 |
136-
| raftstore.region-compact-min-tombstones | 触发 RocksDB compaction 需要的 tombstone 个数 |
137-
| raftstore.region-compact-tombstones-percent | 触发 RocksDB compaction 需要的 tombstone 所占比例 |
138134
| raftstore.pd-heartbeat-tick-interval | 触发 Region 对 PD 心跳的时间间隔 |
139135
| raftstore.pd-store-heartbeat-tick-interval | 触发 store 对 PD 心跳的时间间隔 |
140136
| raftstore.snap-mgr-gc-tick-interval | 触发回收过期 snapshot 文件的时间间隔 |
@@ -188,6 +184,12 @@ show warnings;
188184
| gc.max-write-bytes-per-sec | 一秒可写入 RocksDB 的最大字节数 |
189185
| gc.enable-compaction-filter | 是否使用 compaction filter |
190186
| gc.compaction-filter-skip-version-check | 是否跳过 compaction filter 的集群版本检查(未 release)|
187+
| gc.auto-compaction.check-interval | TiKV 检查是否需要触发自动 RocksDB compaction 的时间间隔 |
188+
| gc.auto-compaction.tombstone-num-threshold | 触发 TiKV 自动 (RocksDB) compaction 需要的 RocksDB tombstone 个数 |
189+
| gc.auto-compaction.tombstone-percent-threshold | 触发 TiKV 自动 (RocksDB) compaction 需要的 RocksDB tombstone 所占比例 |
190+
| gc.auto-compaction.redundant-rows-threshold | 触发 TiKV 自动 (RocksDB) compaction 需要的冗余的 MVCC 数据行数 |
191+
| gc.auto-compaction.redundant-rows-percent-threshold | 触发 TiKV 自动 (RocksDB) compaction 需要的冗余的 MVCC 数据行数所占比例 |
192+
| gc.auto-compaction.bottommost-level-force | 控制是否强制对 RocksDB 最底层文件进行 compaction |
191193
| {db-name}.max-total-wal-size | WAL 总大小限制 |
192194
| {db-name}.max-background-jobs | RocksDB 后台线程个数 |
193195
| {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
@@ -92,4 +92,5 @@ show config where type = 'tikv' and name like '%enable-compaction-filter%';
9292
> 在使用 Compaction Filter 机制时,可能会出现 GC 进度延迟的情况,从而影响 TiKV 扫描性能。当你的负载中含有大量 coprocessor 请求,并且在 [**TiKV-Details > Coprocessor Detail**](/grafana-tikv-dashboard.md#coprocessor-detail) 面板中发现 Total Ops Details 的 `next()``prev()` 调用次数远远超过 `processed_keys` 调用的三倍时,可以采取以下措施:
9393
>
9494
> - 对于 TiDB v7.1.3 之前版本,建议尝试关闭 Compaction Filter,以加快 GC 速度。
95-
> - 从 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。
95+
> - 在 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。
96+
> - 从 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-和-v900-版本开始引入)[`gc.auto-compaction.redundant-rows-percent-threshold`](/tikv-configuration-file.md#redundant-rows-percent-threshold-从-v757-和-v900-版本开始引入) 自动触发 compaction。如果遇到上述情况,建议调整这两个参数,无需关闭 Compaction Filter。

tikv-configuration-file.md

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

819819
### `region-compact-check-interval`
820820

821+
> **警告:**
822+
>
823+
> 从 v7.5.7 和 v9.0.0 开始,该配置项被废弃,其功能由 [`gc.auto-compaction.check-interval`](#check-interval-从-v757-和-v900-版本开始引入) 代替。
824+
821825
+ 检查是否需要人工触发 RocksDB compaction 的时间间隔,0 表示不启用。
822826
+ 默认值:5m
823827
+ 最小值:0
824828

825829
### `region-compact-check-step`
826830

831+
> **警告:**
832+
>
833+
> 从 v7.5.7 和 v9.0.0 开始,该配置项被废弃。
834+
827835
+ 每轮校验人工 compaction 时,一次性检查的 Region 个数。
828836
+ 默认值:
829837
+`storage.engine="raft-kv"` 时,默认值为 100。
830838
+`storage.engine="partitioned-raft-kv"` 时,默认值为 5。
831839

832840
### `region-compact-min-tombstones`
833841

842+
> **警告:**
843+
>
844+
> 从 v7.5.7 和 v9.0.0 开始,该配置项被废弃,其功能由 [`gc.auto-compaction.tombstone-num-threshold`](#tombstone-num-threshold-从-v757-和-v900-版本开始引入) 代替。
845+
834846
+ 触发 RocksDB compaction 需要的 tombstone 个数。
835847
+ 默认值:10000
836848
+ 最小值:0
837849

838850
### `region-compact-tombstones-percent`
839851

852+
> **警告:**
853+
>
854+
> 从 v7.5.7 和 v9.0.0 开始,该配置项被废弃,其功能由 [`gc.auto-compaction.tombstone-percent-threshold`](#tombstone-percent-threshold-从-v757-和-v900-版本开始引入) 代替。
855+
840856
+ 触发 RocksDB compaction 需要的 tombstone 所占比例。
841857
+ 默认值:30
842858
+ 最小值:1
843859
+ 最大值:100
844860

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

863+
> **警告:**
864+
>
865+
> 从 v7.5.7 和 v9.0.0 开始,该配置项被废弃,其功能由 [`gc.auto-compaction.redundant-rows-threshold`](#redundant-rows-threshold-从-v757-和-v900-版本开始引入) 代替。
866+
847867
+ 触发 RocksDB compaction 需要的冗余的 MVCC 数据行数。
848868
+ 默认值:`50000`
849869
+ 最小值:`0`
850870

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

873+
> **警告:**
874+
>
875+
> 从 v7.5.7 和 v9.0.0 开始,该配置项被废弃,其功能由 [`gc.auto-compaction.redundant-rows-percent-threshold`](#redundant-rows-percent-threshold-从-v757-和-v900-版本开始引入) 代替。
876+
853877
+ 触发 RocksDB compaction 需要的冗余的 MVCC 数据行所占比例。
854878
+ 默认值:`20`
855879
+ 最小值:`1`
@@ -2258,6 +2282,50 @@ Raft Engine 相关的配置项。
22582282
+`enable-compaction-filter``false` 时 GC 线程个数。
22592283
+ 默认值:1
22602284

2285+
## gc.auto-compaction
2286+
2287+
用于配置 TiKV 自动 compaction 的行为。
2288+
2289+
### `check-interval` <span class="version-mark">从 v7.5.7 和 v9.0.0 版本开始引入</span>
2290+
2291+
+ TiKV 检查是否需要触发自动 compaction 的时间间隔。在此时间段内,满足自动 compaction 条件的 Region 会按优先级进行处理。当到达此间隔时,TiKV 会重新扫描 Region 信息并重新计算优先级。
2292+
+ 默认值:`"300s"`
2293+
2294+
### `tombstone-num-threshold` <span class="version-mark">从 v7.5.7 和 v9.0.0 版本开始引入</span>
2295+
2296+
+ 触发 TiKV 自动 compaction 需要的 RocksDB tombstone 个数。当 tombstone 数量达到此阈值,或 tombstone 所占比例达到 [`tombstone-percent-threshold`](#tombstone-percent-threshold-从-v757-和-v900-版本开始引入) 时,TiKV 将触发自动 compaction。
2297+
+ 仅在关闭 [Compaction Filter](/garbage-collection-configuration.md) 时生效。
2298+
+ 默认值:`10000`
2299+
+ 最小值:`0`
2300+
2301+
### `tombstone-percent-threshold` <span class="version-mark">从 v7.5.7 和 v9.0.0 版本开始引入</span>
2302+
2303+
+ 触发 TiKV 自动 compaction 需要的 RocksDB tombstone 所占比例。当 tombstone 所占比例达到此阈值,或 tombstone 数量达到 [`tombstone-num-threshold`](#tombstone-num-threshold-从-v757-和-v900-版本开始引入) 时,TiKV 将触发自动 compaction。
2304+
+ 仅在关闭 [Compaction Filter](/garbage-collection-configuration.md) 时生效。
2305+
+ 默认值:`30`
2306+
+ 最小值:`0`
2307+
+ 最大值:`100`
2308+
2309+
### `redundant-rows-threshold` <span class="version-mark">从 v7.5.7 和 v9.0.0 版本开始引入</span>
2310+
2311+
+ 触发 TiKV 自动 compaction 需要的冗余的 MVCC 数据行数,包含 RocksDB tombstone、TiKV stale versions 和 TiKV deletion tombstones。当冗余的 MVCC 数据行数达到此阈值,或这些行数的占比达到 [`redundant-rows-percent-threshold`](#redundant-rows-percent-threshold-从-v757-和-v900-版本开始引入) 时,TiKV 将触发自动 compaction。
2312+
+ 仅在开启 [Compaction Filter](/garbage-collection-configuration.md) 时生效。
2313+
+ 默认值:`50000`
2314+
+ 最小值:`0`
2315+
2316+
### `redundant-rows-percent-threshold` <span class="version-mark">从 v7.5.7 和 v9.0.0 版本开始引入</span>
2317+
2318+
+ 触发 TiKV 自动 compaction 需要的冗余的 MVCC 数据行数所占比例。冗余数据包含 RocksDB tombstone、TiKV stale versions 和 TiKV deletion tombstones。当冗余的 MVCC 数据行数达到 [`redundant-rows-threshold`](#redundant-rows-threshold-从-v757-和-v900-版本开始引入),或这些行数的占比达到 `redundant-rows-percent-threshold` 时,TiKV 将触发自动 compaction。
2319+
+ 仅在开启 [Compaction Filter](/garbage-collection-configuration.md) 时生效。
2320+
+ 默认值:`20`
2321+
+ 最小值:`0`
2322+
+ 最大值:`100`
2323+
2324+
### `bottommost-level-force` <span class="version-mark">从 v7.5.7 和 v9.0.0 版本开始引入</span>
2325+
2326+
+ 控制是否强制对 RocksDB 最底层文件进行 compaction。
2327+
+ 默认值:`true`
2328+
22612329
## backup
22622330

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

0 commit comments

Comments
 (0)