diff --git a/HISTORY.md b/HISTORY.md index f8fd30e95..f2960b164 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -4,6 +4,7 @@ * Fix wrong result being read from ingested file. May happen when a key in the file happen to be prefix of another key also in the file. The issue can further cause more data corruption. The issue exists with rocksdb >= 5.0.0 since DB::IngestExternalFile() was introduced. * Finish implementation of BlockBasedTableOptions::IndexType::kBinarySearchWithFirstKey. It's now ready for use. Significantly reduces read amplification in some setups, especially for iterator seeks. * Fix a bug by updating CURRENT file so that it points to the correct MANIFEST file after best-efforts recovery. +* Fixed a bug where ColumnFamilyHandle objects were not cleaned up in case an error happened during BlobDB's open after the base DB had been opened. ### Public API Change * Add a ConfigOptions argument to the APIs dealing with converting options to and from strings and files. The ConfigOptions is meant to replace some of the options (such as input_strings_escaped and ignore_unknown_options) and allow for more parameters to be passed in the future without changing the function signature. diff --git a/utilities/blob_db/blob_db.cc b/utilities/blob_db/blob_db.cc index f568ecd1a..b756f02c0 100644 --- a/utilities/blob_db/blob_db.cc +++ b/utilities/blob_db/blob_db.cc @@ -38,6 +38,8 @@ Status BlobDB::Open(const DBOptions& db_options, const std::vector& column_families, std::vector* handles, BlobDB** blob_db) { + assert(handles); + if (column_families.size() != 1 || column_families[0].name != kDefaultColumnFamilyName) { return Status::NotSupported( @@ -50,6 +52,14 @@ Status BlobDB::Open(const DBOptions& db_options, if (s.ok()) { *blob_db = static_cast(blob_db_impl); } else { + if (!handles->empty()) { + for (ColumnFamilyHandle* cfh : *handles) { + blob_db_impl->DestroyColumnFamilyHandle(cfh); + } + + handles->clear(); + } + delete blob_db_impl; *blob_db = nullptr; }