facebook / rocksdb

A library that provides an embeddable, persistent key-value store for fast storage.
http://rocksdb.org
GNU General Public License v2.0
28.7k stars 6.33k forks source link

Can I open multiple CF in different DB with one same rocksdb_option_t ? #13133

Open 979357361 opened 1 week ago

979357361 commented 1 week ago

Hi guys, Good day! I have encountered some problem with using RocksDB in C APIs

I wants to open a series of DBs, each DB has one default CF and multiple data CFs, all data CF stores same type of data and is differnt from the default CF, so the rocksdb_option_t for default CF and other CF are not the same, tuning a customed rocksdb_option_t for each CF is tanglesome, especially when many other options are assigned to rocksdb_option_t in different ways, like point directly copy, shared point trans or copy and trans, this makes it complicated to release these structures in the right places. Since all data CFs use the same option tuning, is it OK to open all CFs with one same rocksdb_option_t? For , it sames OK, How about ?

I also run into another question which makes me puzzled. I have set a CompactFilterFactory for data CF rocksdb_option_t, when I call many manul compacts by API with two NULL key range and default compact_opt, it is supported to compact the entire CF data and filter out all staled data, however, only part of staled data are filter out, could this be due to multiple threads initiating compact concurrently? the thread safe of compact filter can be ensured.

thanks for your time! any help is wlecome

cbi42 commented 1 day ago

Using the same option should be fine. Options like block cache will be be shared across CFs.

Manual compaction with default options and compaction filter should compact all keys. Can you check if all keys went through compaction filter?