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.26k stars 6.27k forks source link

There is an bug with CreateColumnFamilyWithImport #12905

Open zaorangyang opened 1 month ago

zaorangyang commented 1 month ago

I'll start by describing my use case. I use ExportColumnFamily to export data from one database, let's call it DB1, as a backup. Then, I create a completely new and empty database on another machine that I call DB2. I use db->CreateColumnFamilyWithImport to import all column families from DB1. However, when I try to import the default column family, RocksDB reports an error similar to 'default column family already exists.' Here lies a contradiction, because for RocksDB, when you open a database handle, you must have a default column family, even if the database is completely empty.

jowlyzhang commented 1 month ago

If this is something you really need, we have a feature working in progress that could suite you. This feature supports the user to swap a set of files into an existing column family to replace its existing data atomically. But for the CreateColumnFamilyWithImport API, I think it's logical that it doesn't support create the default column family. Since you cannot create the default column family with the CreateColumnFamily API either.

zaorangyang commented 1 month ago

Thanks for your reply. Atomic replacement of column families, this feature sounds great. However, in my opinion, the current behavior of the CreateColumnFamilyWithImport API is incomplete in a way. If there are no current plans to support using CreateColumnFamilyWithImport to import the default column family, it would be better to mention this detail in the documentation to prevent confusion for other users.