diff --git a/HISTORY.md b/HISTORY.md index 5574c76987844ca4dc41e8097a2a41c9e6cd736a..228d02b61dff56b595c66258a5afe7152f213aa6 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 af39b5ca11d2ffb021c78d8a00a97d67ed142fd2..154e6dd2339c2bbd30b43dff7178c7fc5662b3f6 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 3bac53f2f0a39f51d0b5729174bfaf2f892e4005..0204f4d9f62d8dcf29a2d2f7f4dffe570d30e8be 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();