Only execute flush from compaction if max_background_flushes = 0

Summary: As title. We shouldn't need to execute flush from compaction if there are dedicated threads doing flushes.

Test Plan: make check

Reviewers: rven, yhchiang, sdong

Reviewed By: sdong

Subscribers: dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D30579
This commit is contained in:
Igor Canadi 2014-12-22 12:05:14 +01:00
parent 0acc738810
commit 4fd26f287c

View File

@ -2018,26 +2018,29 @@ Status DBImpl::BackgroundCompaction(bool* madeProgress, JobContext* job_context,
return Status::OK(); return Status::OK();
} }
// FLUSH preempts compaction // If there are no flush threads, then compaction thread needs to execute the
// TODO(icanadi) we should only do this if max_background_flushes == 0 // flushes
// BackgroundFlush() will only execute a single flush. We keep calling it as if (db_options_.max_background_flushes == 0) {
// long as there's more flushes to be done // BackgroundFlush() will only execute a single flush. We keep calling it as
while (!flush_queue_.empty()) { // long as there's more flushes to be done
LogToBuffer( while (!flush_queue_.empty()) {
log_buffer, LogToBuffer(
"BackgroundCompaction calling BackgroundFlush. flush slots available " log_buffer,
"%d, compaction slots available %d", "BackgroundCompaction calling BackgroundFlush. flush slots available "
db_options_.max_background_flushes - bg_flush_scheduled_, "%d, compaction slots available %d",
db_options_.max_background_compactions - bg_compaction_scheduled_); db_options_.max_background_flushes - bg_flush_scheduled_,
auto flush_status = BackgroundFlush(madeProgress, job_context, log_buffer); db_options_.max_background_compactions - bg_compaction_scheduled_);
if (!flush_status.ok()) { auto flush_status =
if (is_manual) { BackgroundFlush(madeProgress, job_context, log_buffer);
manual_compaction_->status = flush_status; if (!flush_status.ok()) {
manual_compaction_->done = true; if (is_manual) {
manual_compaction_->in_progress = false; manual_compaction_->status = flush_status;
manual_compaction_ = nullptr; manual_compaction_->done = true;
manual_compaction_->in_progress = false;
manual_compaction_ = nullptr;
}
return flush_status;
} }
return flush_status;
} }
} }