diff --git a/HISTORY.md b/HISTORY.md index 5574c7698..228d02b61 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -22,6 +22,7 @@ ### General Improvements * Added new status code kColumnFamilyDropped to distinguish between Column Family Dropped and DB Shutdown in progress. +* Improve ColumnFamilyOptions validation when creating a new column family. ### Bug Fixes * Fix a bug in WAL replay of secondary instance by skipping write batches with older sequence numbers than the current last sequence number. diff --git a/db/db_impl/db_impl.cc b/db/db_impl/db_impl.cc index af39b5ca1..154e6dd23 100644 --- a/db/db_impl/db_impl.cc +++ b/db/db_impl/db_impl.cc @@ -1944,13 +1944,9 @@ Status DBImpl::CreateColumnFamilyImpl(const ColumnFamilyOptions& cf_options, Status persist_options_status; *handle = nullptr; - s = CheckCompressionSupported(cf_options); - if (s.ok() && immutable_db_options_.allow_concurrent_memtable_write) { - s = CheckConcurrentWritesSupported(cf_options); - } - if (s.ok()) { - s = CheckCFPathsSupported(initial_db_options_, cf_options); - } + DBOptions db_options = + BuildDBOptions(immutable_db_options_, mutable_db_options_); + s = ColumnFamilyData::ValidateOptions(db_options, cf_options); if (s.ok()) { for (auto& cf_path : cf_options.cf_paths) { s = env_->CreateDirIfMissing(cf_path.path); diff --git a/db/db_test.cc b/db/db_test.cc index 3bac53f2f..0204f4d9f 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -5978,6 +5978,19 @@ TEST_F(DBTest, FailWhenCompressionNotSupportedTest) { } } +TEST_F(DBTest, CreateColumnFamilyShouldFailOnIncompatibleOptions) { + Options options = CurrentOptions(); + options.max_open_files = 100; + Reopen(options); + + ColumnFamilyOptions cf_options(options); + // ttl is only supported when max_open_files is -1. + cf_options.ttl = 3600; + ColumnFamilyHandle* handle; + ASSERT_NOK(db_->CreateColumnFamily(cf_options, "pikachu", &handle)); + delete handle; +} + #ifndef ROCKSDB_LITE TEST_F(DBTest, RowCache) { Options options = CurrentOptions();