Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 删除数据库,磁盘空间没变少
【TiDB Usage Environment】Production Environment
【TiDB Version】v6.5.1
I deleted dozens of databases, but the disk space did not decrease. What could be the problem?
The default GC time is ten minutes. You can check it again later.
You need to wait for a while.
After deleting data in TiDB, the kv segments to be cleaned are first written into mysql.gc_delete_range, which contains a ts recording the timestamp of the deletion.
Then, it checks once every @@tidb_gc_run_interval. If the current cluster’s min(minStartTs, now) + @@tidb_gc_life_time > ts, it will actually clean up.
So the data might not be cleaned up due to:
- @@tidb_gc_run_interval hasn’t reached yet, and the cleanup logic hasn’t started.
- @@tidb_gc_life_time hasn’t passed yet, so the data is still alive.
- There is an ongoing txn that is blocking the calculation of min(minStartTs, now).
You can specifically search for “[gc worker]” in the TiDB log (only one TiDB will become the gc leader, so you might need to check around).
I have already deleted it several days ago.
Will this have an impact?
select * from mysql.tidb to check the progress of GC
The image you provided is not visible. Please provide the text you need translated.
Excluding issues with TiDB itself, it is possible that disk space has not been released. Try using lsof | grep deleted
.
Is there a way to check for invalid regions?
In the PD monitoring panel, there are empty regions.
There are no invalid regions.
All regions are connected sequentially. It only means that the data in the middle of this range has been completely deleted, making this region empty. It does not mean that this range has disappeared.
Check the number of empty regions in Grafana, it should release a lot.
Check the PD scheduling to see if the region merging is slow.
It should be related to RocksDB’s compaction.
Manual compaction can be triggered.
GC cleanup indeed takes time. You can adjust the parameters to shorten the interval for GC to clean up garbage data.
Check if there is any content in select count(*) from mysql.gc_delete_range;
, and see if there is the phrase gc work is too busy
in the TiDB log.
The GC time you set hasn’t arrived yet, right?
Search for manually merging regions and deleting redundant, invalid empty regions.