diff --git a/db/flush_job.cc b/db/flush_job.cc index 9ce20b2b4..3a258a57e 100644 --- a/db/flush_job.cc +++ b/db/flush_job.cc @@ -577,12 +577,9 @@ Status FlushJob::MemPurge() { } new_mem->SetID(new_mem_id); cfd_->imm()->AddMemPurgeOutputID(new_mem_id); - cfd_->imm()->Add(new_mem, - &job_context_->memtables_to_free, - false /* -> trigger_flush=false: - * adding this memtable - * will not trigger a flush. - */); + // This addition will not trigger another flush, because + // we do not call SchedulePendingFlush(). + cfd_->imm()->Add(new_mem, &job_context_->memtables_to_free); new_mem_capacity = (new_mem->ApproximateMemoryUsage()) * 1.0 / mutable_cf_options_.write_buffer_size; new_mem->Ref(); diff --git a/db/memtable_list.cc b/db/memtable_list.cc index 36bdd98f5..c35ebd5a5 100644 --- a/db/memtable_list.cc +++ b/db/memtable_list.cc @@ -539,8 +539,7 @@ Status MemTableList::TryInstallMemtableFlushResults( } // New memtables are inserted at the front of the list. -void MemTableList::Add(MemTable* m, autovector* to_delete, - bool trigger_flush) { +void MemTableList::Add(MemTable* m, autovector* to_delete) { assert(static_cast(current_->memlist_.size()) >= num_flush_not_started_); InstallNewVersion(); // this method is used to move mutable memtable into an immutable list. @@ -551,8 +550,7 @@ void MemTableList::Add(MemTable* m, autovector* to_delete, current_->Add(m, to_delete); m->MarkImmutable(); num_flush_not_started_++; - - if (num_flush_not_started_ > 0 && trigger_flush) { + if (num_flush_not_started_ == 1) { imm_flush_needed.store(true, std::memory_order_release); } UpdateCachedValuesFromMemTableListVersion(); diff --git a/db/memtable_list.h b/db/memtable_list.h index ada6469a1..9ae50e47f 100644 --- a/db/memtable_list.h +++ b/db/memtable_list.h @@ -275,8 +275,7 @@ class MemTableList { // By default, adding memtables will flag that the memtable list needs to be // flushed, but in certain situations, like after a mempurge, we may want to // avoid flushing the memtable list upon addition of a memtable. - void Add(MemTable* m, autovector* to_delete, - bool trigger_flush = true); + void Add(MemTable* m, autovector* to_delete); // Returns an estimate of the number of bytes of data in use. size_t ApproximateMemoryUsage();