Skip to content

Commit

Permalink
update GC for release 5.0 (pingcap#5092)
Browse files Browse the repository at this point in the history
* update GC for release 5.0

Signed-off-by: qupeng <[email protected]>

* address comments

Signed-off-by: qupeng <[email protected]>

* address comments

Signed-off-by: qupeng <[email protected]>

* Apply suggestions from code review

* Update garbage-collection-configuration.md

Co-authored-by: TomShawn <[email protected]>
  • Loading branch information
hicqu and TomShawn authored Dec 24, 2020
1 parent 62d39ad commit b9b1796
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
48 changes: 47 additions & 1 deletion garbage-collection-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ update mysql.tidb set VARIABLE_VALUE="24h" where VARIABLE_NAME="tikv_gc_life_tim

- `"distributed"`(默认):分布式 GC 模式。在此模式下,[Do GC](/garbage-collection-overview.md#do-gc进行-gc-清理) 阶段由 TiDB 上的 GC leader 向 PD 发送 safe point,每个 TiKV 节点各自获取该 safe point 并对所有当前节点上作为 leader 的 Region 进行 GC。此模式于 TiDB 3.0 引入。

- `"central"`:集中 GC 模式。在此模式下,[Do GC](/garbage-collection-overview.md#do-gc进行-gc-清理) 阶段由 GC leader 向所有的 Region 发送 GC 请求。TiDB 2.1 及更早版本采用此 GC 模式。
- `"central"`:集中 GC 模式。在此模式下,[Do GC](/garbage-collection-overview.md#do-gc进行-gc-清理) 阶段由 GC leader 向所有的 Region 发送 GC 请求。TiDB 2.1 及更早版本采用此 GC 模式。从 TiKV 5.0 起不再支持该模式,设置该模式的集群将切换到 `distributed` 模式。

## `tikv_gc_auto_concurrency`

Expand Down Expand Up @@ -142,3 +142,49 @@ TiKV 在 3.0.6 版本开始支持 GC 流控,可通过配置 `gc.max-write-byte
```bash
tikv-ctl --host=ip:port modify-tikv-config -m server -n gc.max_write_bytes_per_sec -v 10MB
```
## GC in Compaction Filter 机制

TiKV 在 5.0 版本中引入了 GC in Compaction Filter 机制。在分布式 GC 模式 (distributed GC) 的基础上,由 RocksDB 的 Compaction 过程来进行 GC,而不再使用一个单独的 GC worker 线程。这样做的好处是避免了 GC 引起的额外磁盘读取,以及避免清理掉的旧版本残留大量删除标记影响顺序扫描性能。该 GC 机制默认开启,同时支持滚动升级完成之后静默开启。可以由 TiKV 配置文件中的以下开关控制:

{{< copyable "" >}}

```toml
[gc]
enable-compaction-filter = true
```

该 GC 机制可通过在线配置变更开启:

{{< copyable "sql" >}}

```sql
show config where type = 'tikv' and name like '%enable-compaction-filter%';
```

```sql
+------+-------------------+-----------------------------+-------+
| Type | Instance | Name | Value |
+------+-------------------+-----------------------------+-------+
| tikv | 172.16.5.37:20163 | gc.enable-compaction-filter | false |
| tikv | 172.16.5.36:20163 | gc.enable-compaction-filter | false |
| tikv | 172.16.5.35:20163 | gc.enable-compaction-filter | false |
+------+-------------------+-----------------------------+-------+
```

{{< copyable "sql" >}}

```sql
set config tikv gc.enable-compaction-filter = true;
show config where type = 'tikv' and name like '%enable-compaction-filter%';
```

```sql
+------+-------------------+-----------------------------+-------+
| Type | Instance | Name | Value |
+------+-------------------+-----------------------------+-------+
| tikv | 172.16.5.37:20163 | gc.enable-compaction-filter | true |
| tikv | 172.16.5.36:20163 | gc.enable-compaction-filter | true |
| tikv | 172.16.5.35:20163 | gc.enable-compaction-filter | true |
+------+-------------------+-----------------------------+-------+
```
7 changes: 7 additions & 0 deletions tikv-configuration-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,13 @@ raftdb 相关配置项。
+ 默认值:8
+ 最小值:1

## gc

### `enable-compaction-filter`

+ 是否开启 GC in Compaction Filter 特性
+ 默认值:true

## backup

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

0 comments on commit b9b1796

Please sign in to comment.