RocksDB is not freeing up space after a delete

739 Views Asked by At

Most of our services are using a Kafka store, which as you know is using RocksDB under the hood. We are trying to delete outdated and wrongly formatted records every 6 hours, in order to free up space. Even though the record gets deleted from RocksDB (a tombstone gets added and the record is no longer available), we see no changes in space.

I suppose, that a compaction needs to be triggered, in order compact away the deleted records. However, as far as I know, a leveled compaction gets triggered only when number of L0 files reaches level0_file_num_compaction_trigger. Because of the fact, that my service is consuming almost no data (on dev environment), I believe, that a compaction cannot be triggered and therefore the "deleted" records remain.

Please note, that we are using only the default RocksDB configuration. I also noticed, that when I use #options.setDeleteObsoleteFilesPeriodMicros() in a custom RocksDB config, the size of the local store drops dramatically. However, I am not sure, what the method does exactly.

I also read, that there is an option for a periodic compaction by using a compaction filter. However, I am not sure how to add one using Java.

1

There are 1 best solutions below

0
On

If you have access to the rocksdb object on the data folder - you can call compactRange yourself