What does gc-threshold mean?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: gc-threshold代表啥意思

| username: 特雷西-迈克-格雷迪

[TiDB Usage Environment] Production Environment
[TiDB Version] 6.1.2
[Reproduction Path]
[Encountered Problem: Problem Phenomenon and Impact]

What does the gc-threshold metric under the Grafana monitoring “ienjoys-tidb-prod / ienjoys-tidb-prod-TiDB-Runtime” represent? What operation’s GC is it?

[Attachment: Screenshot/Log/Monitoring]

| username: Billmay表妹 | Original post link

In Grafana monitoring, the gc-threshold metric under “ienjoys-tidb-prod / ienjoys-tidb-prod-TiDB-Runtime” represents the GC threshold of TiDB.

GC (Garbage Collection) is an important operation in TiDB used to clean up invalid data and free up storage space. GC deletes expired or marked-for-deletion data and recycles the corresponding storage space to keep the database tidy and efficient.

The gc-threshold metric indicates the GC threshold of TiDB. The GC threshold refers to the condition that triggers the GC operation when the number of data versions in TiDB reaches a certain threshold. When the number of data versions exceeds the GC threshold, GC will be triggered to perform the corresponding cleanup operations.

The specific operations of GC include two stages: Resolve Locks and TiKV Auto GC. The Resolve Locks stage is used to resolve locked transactions, while the TiKV Auto GC stage is the actual data cleanup operation.

By monitoring the gc-threshold metric, you can understand the GC threshold situation in TiDB and determine whether a GC operation is needed to clean up invalid data and free up storage space.

| username: dba远航 | Original post link

The gc-threshold metric represents the GC threshold in TiDB.

| username: 哈喽沃德 | Original post link

A smaller gc-threshold value may increase the burden of garbage collection and affect system performance.

| username: YuchongXU | Original post link

Memory garbage collection

| username: zhang_2023 | Original post link

GC threshold

| username: 特雷西-迈克-格雷迪 | Original post link

Why does GC affect the memory of the TiDB server component? Isn’t GC completed in the TiKV component?

| username: Kongdom | Original post link

There are value descriptions below the chart.

| username: Kongdom | Original post link

In a TiDB cluster, one TiDB instance will be elected as the GC leader, and the GC operation is controlled by the GC leader.

| username: 特雷西-迈克-格雷迪 | Original post link

Master, what I mean is why does the TiDB server component have GC operations? Isn’t garbage collection the responsibility of TiKV?

| username: Kongdom | Original post link

:flushed: The document above describes that the GC operation is controlled by the TiDB component, and it is normal for the TiDB component to record the GC threshold. The actual execution is carried out in TiKV, but the control is completed in the TiDB component.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.