diff --git a/db/db_impl/db_impl.cc b/db/db_impl/db_impl.cc index ace2899e980..1af0a1fecaa 100644 --- a/db/db_impl/db_impl.cc +++ b/db/db_impl/db_impl.cc @@ -453,7 +453,7 @@ Status DBImpl::ResumeImpl(DBRecoverContext context) { if (shutdown_initiated_) { s = Status::ShutdownInProgress(); } - if (s.ok()) { + if (s.ok() && context.flush_after_recovery) { // Since we drop all non-recovery flush requests during recovery, // and new memtable may fill up during recovery, // schedule one more round of flush. @@ -472,14 +472,16 @@ Status DBImpl::ResumeImpl(DBRecoverContext context) { // FlushAllColumnFamilies releases and re-acquires mutex. if (shutdown_initiated_) { s = Status::ShutdownInProgress(); - } else { - for (auto cfd : *versions_->GetColumnFamilySet()) { - SchedulePendingCompaction(cfd); - } - MaybeScheduleFlushOrCompaction(); } } + if (s.ok()) { + for (auto cfd : *versions_->GetColumnFamilySet()) { + SchedulePendingCompaction(cfd); + } + MaybeScheduleFlushOrCompaction(); + } + // Wake up any waiters - in this case, it could be the shutdown thread bg_cv_.SignalAll(); diff --git a/db/error_handler.cc b/db/error_handler.cc index d7945550932..ddcfa5401ad 100644 --- a/db/error_handler.cc +++ b/db/error_handler.cc @@ -679,6 +679,7 @@ void ErrorHandler::RecoverFromRetryableBGIOError() { return; } DBRecoverContext context = recover_context_; + context.flush_after_recovery = true; int resume_count = db_options_.max_bgerror_resume_count; uint64_t wait_interval = db_options_.bgerror_resume_retry_interval; uint64_t retry_count = 0; diff --git a/db/error_handler.h b/db/error_handler.h index 34e08a525d7..6b1e8028636 100644 --- a/db/error_handler.h +++ b/db/error_handler.h @@ -19,10 +19,13 @@ class DBImpl; // FlushReason, which tells the flush job why this flush is called. struct DBRecoverContext { FlushReason flush_reason; + bool flush_after_recovery; - DBRecoverContext() : flush_reason(FlushReason::kErrorRecovery) {} - - DBRecoverContext(FlushReason reason) : flush_reason(reason) {} + DBRecoverContext() + : flush_reason(FlushReason::kErrorRecovery), + flush_after_recovery(false) {} + DBRecoverContext(FlushReason reason) + : flush_reason(reason), flush_after_recovery(false) {} }; class ErrorHandler {