Skip to content

Commit d461c0b

Browse files
committed
initial implementation, might not compile
1 parent d6214b7 commit d461c0b

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

db/db_impl/db_impl_compaction_flush.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,13 +1704,15 @@ Status DBImpl::Flush(const FlushOptions& flush_options,
17041704
ROCKS_LOG_INFO(immutable_db_options_.info_log, "[%s] Manual flush start.",
17051705
cfh->GetName().c_str());
17061706
Status s;
1707+
cfh->imm.BeginManualOperation();
17071708
if (immutable_db_options_.atomic_flush) {
17081709
s = AtomicFlushMemTables({cfh->cfd()}, flush_options,
17091710
FlushReason::kManualFlush);
17101711
} else {
17111712
s = FlushMemTable(cfh->cfd(), flush_options, FlushReason::kManualFlush);
17121713
}
17131714

1715+
cfh->imm.CompleteManualOperation();
17141716
ROCKS_LOG_INFO(immutable_db_options_.info_log,
17151717
"[%s] Manual flush finished, status: %s\n",
17161718
cfh->GetName().c_str(), s.ToString().c_str());

db/memtable_list.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,8 @@ bool MemTableListVersion::TrimHistory(autovector<MemTable*>* to_delete,
329329
// not yet started.
330330
bool MemTableList::IsFlushPending() const {
331331
if ((flush_requested_ && num_flush_not_started_ > 0) ||
332-
(num_flush_not_started_ >= min_write_buffer_number_to_merge_)) {
332+
(num_flush_not_started_ >= min_write_buffer_number_to_merge_) ||
333+
(active_manuals_ && num_flush_not_started_)) {
333334
assert(imm_flush_needed.load(std::memory_order_relaxed));
334335
return true;
335336
}

db/memtable_list.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,12 @@ class MemTableList {
391391
void RemoveOldMemTables(uint64_t log_number,
392392
autovector<MemTable*>* to_delete);
393393

394+
void BeginManualOperation() {++active_manuals_};
395+
396+
void CompleteManualOperation() {
397+
assert(active_manuals >= 1);
398+
--active_manuals_};
399+
394400
private:
395401
friend Status InstallMemtableAtomicFlushResults(
396402
const autovector<MemTableList*>* imm_lists,
@@ -436,6 +442,9 @@ class MemTableList {
436442

437443
// Cached value of current_->HasHistory().
438444
std::atomic<bool> current_has_history_;
445+
446+
// count of manual flush/compactions active
447+
std::atomic<int> active_manuals_{0};
439448
};
440449

441450
// Installs memtable atomic flush results.

0 commit comments

Comments
 (0)