How rocksdb delete key works

569 views Asked by At

I'm trying to learn how rocksdb works under the hood. I understand that each SST file has a bloom filter, to indicate whether a key belongs to the file or not. But what happens when a key is deleted from the file? Bloom filter doesn't support deletions so a new bloom filter is created instead?

2

There are 2 answers

0
cbi On

If a key is deleted, RocksDB creates a deletion marker (tombstone) for it, which is later persisted in SST files. Tombstones in an SST file will be added to the file's bloom filter.

0
Asad Awadia On

bloom filter, to indicate whether a key belongs to the file or not.

The bloom filter is to speed up the check whether a key is contained in the file or not. That is why the api is called keyMayExist since it is probabilistic

Bloom filter doesn't support deletions so a new bloom filter is created instead?

No - nothing to do with bloom filters

what happens when a key is deleted from the file

First it is deleted from the memtable and when the data is flushed to disk a marker is stored that key xyz has been deleted

I'm trying to learn how rocksdb works under the hood.

Watch the video https://youtu.be/7QHI7JQEc5c?t=1281