From 0a74e1b958f735fd2d79e2efa6e81f3c62c029c2 Mon Sep 17 00:00:00 2001 From: Cheng Chang Date: Fri, 7 Feb 2020 12:29:41 -0800 Subject: [PATCH] Add status checks during DB::Open (#6380) Summary: Several statuses were not checked during DB::Open. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6380 Test Plan: make check Differential Revision: D19780237 Pulled By: cheng-chang fbshipit-source-id: c8d189d20344bd1607890dd1449345bda2ef96b9 --- db/db_impl/db_impl_open.cc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/db/db_impl/db_impl_open.cc b/db/db_impl/db_impl_open.cc index 2397d8ca7..6546a27c3 100644 --- a/db/db_impl/db_impl_open.cc +++ b/db/db_impl/db_impl_open.cc @@ -442,19 +442,19 @@ Status DBImpl::Recover( assert(s.IsIOError()); return s; } - GetDbIdentityFromIdentityFile(&db_id_); - if (immutable_db_options_.write_dbid_to_manifest) { + s = GetDbIdentityFromIdentityFile(&db_id_); + if (immutable_db_options_.write_dbid_to_manifest && s.ok()) { VersionEdit edit; edit.SetDBId(db_id_); Options options; MutableCFOptions mutable_cf_options(options); versions_->db_id_ = db_id_; - versions_->LogAndApply(versions_->GetColumnFamilySet()->GetDefault(), + s = versions_->LogAndApply(versions_->GetColumnFamilySet()->GetDefault(), mutable_cf_options, &edit, &mutex_, nullptr, false); } } else { - SetIdentityFile(env_, dbname_, db_id_); + s = SetIdentityFile(env_, dbname_, db_id_); } if (immutable_db_options_.paranoid_checks && s.ok()) { @@ -474,16 +474,16 @@ Status DBImpl::Recover( s = InitPersistStatsColumnFamily(); } - // Initial max_total_in_memory_state_ before recovery logs. Log recovery - // may check this value to decide whether to flush. - max_total_in_memory_state_ = 0; - for (auto cfd : *versions_->GetColumnFamilySet()) { - auto* mutable_cf_options = cfd->GetLatestMutableCFOptions(); - max_total_in_memory_state_ += mutable_cf_options->write_buffer_size * - mutable_cf_options->max_write_buffer_number; - } - if (s.ok()) { + // Initial max_total_in_memory_state_ before recovery logs. Log recovery + // may check this value to decide whether to flush. + max_total_in_memory_state_ = 0; + for (auto cfd : *versions_->GetColumnFamilySet()) { + auto* mutable_cf_options = cfd->GetLatestMutableCFOptions(); + max_total_in_memory_state_ += mutable_cf_options->write_buffer_size * + mutable_cf_options->max_write_buffer_number; + } + SequenceNumber next_sequence(kMaxSequenceNumber); default_cf_handle_ = new ColumnFamilyHandleImpl( versions_->GetColumnFamilySet()->GetDefault(), this, &mutex_);