diff --git a/db/compaction_job.cc b/db/compaction_job.cc index 3395085a9..91bea0601 100644 --- a/db/compaction_job.cc +++ b/db/compaction_job.cc @@ -455,14 +455,14 @@ Status CompactionJob::Run() { return status; } -Status CompactionJob::Install(Status status, port::Mutex* db_mutex) { +void CompactionJob::Install(Status* status, port::Mutex* db_mutex) { db_mutex->AssertHeld(); ColumnFamilyData* cfd = compact_->compaction->column_family_data(); cfd->internal_stats()->AddCompactionStats( compact_->compaction->output_level(), compaction_stats_); - if (status.ok()) { - status = InstallCompactionResults(db_mutex); + if (status->ok()) { + *status = InstallCompactionResults(db_mutex); } VersionStorageInfo::LevelSummaryStorage tmp; const auto& stats = compaction_stats_; @@ -483,11 +483,10 @@ Status CompactionJob::Install(Status status, port::Mutex* db_mutex) { (stats.bytes_written + stats.bytes_readnp1 + stats.bytes_readn) / static_cast(stats.bytes_readn), stats.bytes_written / static_cast(stats.bytes_readn), - status.ToString().c_str(), stats.num_input_records, + status->ToString().c_str(), stats.num_input_records, stats.num_dropped_records); - CleanupCompaction(status); - return status; + CleanupCompaction(*status); } Status CompactionJob::ProcessKeyValueCompaction(int64_t* imm_micros, @@ -1054,7 +1053,7 @@ Status CompactionJob::OpenCompactionOutputFile() { return s; } -void CompactionJob::CleanupCompaction(Status status) { +void CompactionJob::CleanupCompaction(const Status& status) { if (compact_->builder != nullptr) { // May happen if we get a shutdown call in the middle of compaction compact_->builder->Abandon(); diff --git a/db/compaction_job.h b/db/compaction_job.h index e993ea675..4ce440a36 100644 --- a/db/compaction_job.h +++ b/db/compaction_job.h @@ -75,7 +75,7 @@ class CompactionJob { Status Run(); // REQUIRED: mutex held // status is the return of Run() - Status Install(Status status, port::Mutex* db_mutex); + void Install(Status* status, port::Mutex* db_mutex); private: void AllocateCompactionOutputFileNumbers(); @@ -92,7 +92,7 @@ class CompactionJob { SequenceNumber* prev_snapshot); void RecordCompactionIOStats(); Status OpenCompactionOutputFile(); - void CleanupCompaction(Status status); + void CleanupCompaction(const Status& status); // CompactionJob state struct CompactionState; diff --git a/db/db_impl.cc b/db/db_impl.cc index 8ac509249..893dfdee7 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -1295,12 +1295,10 @@ Status DBImpl::CompactFilesImpl( mutex_.Unlock(); Status status = compaction_job.Run(); mutex_.Lock(); + compaction_job.Install(&status, &mutex_); if (status.ok()) { - status = compaction_job.Install(status, &mutex_); - if (status.ok()) { - InstallSuperVersionBackground(c->column_family_data(), &job_context, - *c->mutable_cf_options()); - } + InstallSuperVersionBackground(c->column_family_data(), &job_context, + *c->mutable_cf_options()); } c->ReleaseCompactionFiles(s); c->ReleaseInputs(); @@ -2070,7 +2068,7 @@ Status DBImpl::BackgroundCompaction(bool* madeProgress, JobContext* job_context, mutex_.Unlock(); status = compaction_job.Run(); mutex_.Lock(); - status = compaction_job.Install(status, &mutex_); + compaction_job.Install(&status, &mutex_); if (status.ok()) { InstallSuperVersionBackground(c->column_family_data(), job_context, *c->mutable_cf_options());