Dropping the database will clean up the space completely

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

Original topic: drop database 空间会清理完毕

| username: xingzhenxiang

[Test Environment for TiDB]
[TiDB Version]
[Reproduction Path] drop database
[Encountered Issue: Symptoms and Impact]
[Resource Configuration]
[Attachments: Screenshots/Logs/Monitoring]
The space will be cleaned up after dropping the database.
Before deletion:

After deletion:

| username: 小龙虾爱大龙虾 | Original post link

What do you want to ask? :joy_cat:

| username: xingzhenxiang | Original post link

Why does the space still increase after executing drop database region? How long does it take for the space to be released?

| username: xingzhenxiang | Original post link

Space starts to decrease after 15 minutes.


| username: zhanggame1 | Original post link

After the drop deletion, the space will be released after the next GC, which is by default every 10 minutes.

| username: xingzhenxiang | Original post link

It was precisely because the operation didn’t drop for ten minutes that I got a bit anxious and asked. Haha, I feel relieved after cleaning the machine.

| username: zhanggame1 | Original post link

The ten minutes is not counted from the completion of the operation. The GC runs every ten minutes and each time it checks if the deletion time of the deleted objects is already more than ten minutes. So it definitely takes more than ten minutes.

| username: 小龙虾爱大龙虾 | Original post link

Yes, you are right.

| username: TIDB-Learner | Original post link

The principle of deleting data is to mark the data as deleted rather than immediately removing it from the disk. This is because the data on the disk needs to be periodically cleaned to improve database performance. Deleting a large amount of data can lead to disk space being occupied, so a mechanism called “delayed clean” is used. This is part of the GC (Garbage Collection) mechanism.

| username: xingzhenxiang | Original post link

Is the delay of about five minutes due to this mechanism?

| username: dba远航 | Original post link

The GC cleanup mechanism is executed every 10 minutes by default, so it’s not that fast.

| username: zhanggame1 | Original post link

It is not 5 minutes slower; normally, it takes more than 10 minutes to clean up after deletion, not just 10 minutes.

| username: andone | Original post link

The duration is based on tidb_gc_life_time. The default value is 10 minutes.

| username: 路在何chu | Original post link

GC will release it.

| username: system | Original post link

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