Skip to content

Commit

Permalink
initial implementation, might not compile
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewvon committed Jan 23, 2025
1 parent d6214b7 commit d461c0b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions db/db_impl/db_impl_compaction_flush.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1704,13 +1704,15 @@ Status DBImpl::Flush(const FlushOptions& flush_options,
ROCKS_LOG_INFO(immutable_db_options_.info_log, "[%s] Manual flush start.",
cfh->GetName().c_str());
Status s;
cfh->imm.BeginManualOperation();
if (immutable_db_options_.atomic_flush) {
s = AtomicFlushMemTables({cfh->cfd()}, flush_options,
FlushReason::kManualFlush);
} else {
s = FlushMemTable(cfh->cfd(), flush_options, FlushReason::kManualFlush);
}

cfh->imm.CompleteManualOperation();
ROCKS_LOG_INFO(immutable_db_options_.info_log,
"[%s] Manual flush finished, status: %s\n",
cfh->GetName().c_str(), s.ToString().c_str());
Expand Down
3 changes: 2 additions & 1 deletion db/memtable_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ bool MemTableListVersion::TrimHistory(autovector<MemTable*>* to_delete,
// not yet started.
bool MemTableList::IsFlushPending() const {
if ((flush_requested_ && num_flush_not_started_ > 0) ||
(num_flush_not_started_ >= min_write_buffer_number_to_merge_)) {
(num_flush_not_started_ >= min_write_buffer_number_to_merge_) ||
(active_manuals_ && num_flush_not_started_)) {
assert(imm_flush_needed.load(std::memory_order_relaxed));
return true;
}
Expand Down
9 changes: 9 additions & 0 deletions db/memtable_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,12 @@ class MemTableList {
void RemoveOldMemTables(uint64_t log_number,
autovector<MemTable*>* to_delete);

void BeginManualOperation() {++active_manuals_};

void CompleteManualOperation() {
assert(active_manuals >= 1);
--active_manuals_};

private:
friend Status InstallMemtableAtomicFlushResults(
const autovector<MemTableList*>* imm_lists,
Expand Down Expand Up @@ -436,6 +442,9 @@ class MemTableList {

// Cached value of current_->HasHistory().
std::atomic<bool> current_has_history_;

// count of manual flush/compactions active
std::atomic<int> active_manuals_{0};
};

// Installs memtable atomic flush results.
Expand Down

0 comments on commit d461c0b

Please sign in to comment.