TiDB Table Data Cannot Be Garbage Collected, Leading to Extremely Slow Queries

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

Original topic: TiDB 表数据无法GC导致查询巨慢

| username: yuqi1129

[TiDB Usage Environment] Production Environment / Test / PCO
Production
[TiDB Version]
5.1.0
[Encountered Problem]
select * from nrdc_bi.ads_appointment_detail_d limit 1;

This SQL query takes more than 1 minute. The table has only 150,000 rows according to count(*). Upon investigation, this table has 280 data regions (excluding Index). Further inspection using tikv clt revealed that one of the regions contains a large amount of old version data that has not been GC’d.

The delete commit_ts in this screenshot is from August 18th, and the GC time is 24 hours. Theoretically, the data should have been deleted long ago, but it hasn’t been, resulting in a table with 150,000 rows having 280 regions.

After checking the TiDB GC worker logs for August 18th and 19th, there doesn’t seem to be any anomalies.

Other tables of similar scale in the same cluster, even those an order of magnitude larger, return results instantly with a limit n query. Only this table has the issue.
Could you please advise on how to handle this?
[Reproduction Path] Actions taken that led to the problem
[Problem Phenomenon and Impact]

[Attachments]

Please provide the version information of each component, such as cdc/tikv, which can be obtained by executing cdc version/tikv-server --version.

| username: songxuecheng | Original post link

Refer to this: TiKV GcKeys task doesn't work when called with multiple keys (at least in 5.1 but I think for everything) · Issue #11217 · tikv/tikv · GitHub and see if there is a similar situation.

| username: h5n1 | Original post link

Refer to bug-11217: Multi-key GC call causes GC not to work, leaving a large number of historical versions

If possible, rebuild this table to temporarily resolve the issue, and upgrade the version later.

| username: yuqi1129 | Original post link

Thank you, master. This should be the problem.

| username: yuqi1129 | Original post link

Thank you, thank you, this is indeed the issue~~~

| username: xiaohetao | Original post link

:+1::+1::+1:

| username: alfred | Original post link

It seems that some issues need to match the bug first.

| username: Kongdom | Original post link

:wink: Get new skills right away! :+1:

| username: system | Original post link

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