Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 为何UnsafeDestroyRange有一定概率删数据删不干净?
[TiDB Usage Environment] Production Environment
[TiDB Version] Not using TiKV, only using TiKV for KV storage, using TxnClient
[Encountered Issues]
-
UnsafeDestroyRange has a certain probability of failing to delete data. During testing, it was found that there is a certain probability (about 6%) that data intended to be destroyed by DestroyRange can still be scanned by txn.Iter. Why is this happening? I briefly reviewed the TiKV code. Currently, its implementation first calls Rocksdb::DeleteFilesInRange to attempt to quickly free up space. If that fails, it iterates and writes tombstones one by one. However, I don’t understand why data remnants appear. Additionally, can the individual Deletes be replaced with Rocksdb::DeleteRange to write RangeTombstones? Because it seems that iterating and deleting one by one might be a bit costly, and the GCWorker’s queue can easily get filled up.
-
Performing UnsafeDestroyRange on a very large range (above TB level) will cause TiKV’s IO to be maxed out, lasting for several hours. Is there a good solution for this?
I hope someone from the official team can clarify these issues. Thank you very much!