Skip to content

Commit

Permalink
PLAT-7494: rocksdb stall on manual Flush() and CompactRange() (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewvon authored Jan 31, 2025
1 parent d6214b7 commit bb35552
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
8 changes: 8 additions & 0 deletions db/db_impl/db_impl_compaction_flush.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1989,6 +1989,10 @@ Status DBImpl::FlushMemTable(ColumnFamilyData* cfd,
}
}

if (flush_reason == FlushReason::kManualCompaction ||
flush_reason == FlushReason::kManualFlush) {
cfd->imm()->BeginManualOperation();
}
autovector<FlushRequest> flush_reqs;
autovector<uint64_t> memtable_ids_to_wait;
{
Expand Down Expand Up @@ -2107,6 +2111,10 @@ Status DBImpl::FlushMemTable(ColumnFamilyData* cfd,
tmp_cfd->UnrefAndTryDelete();
}
}
if (flush_reason == FlushReason::kManualCompaction ||
flush_reason == FlushReason::kManualFlush) {
cfd->imm()->CompleteManualOperation();
}
TEST_SYNC_POINT("DBImpl::FlushMemTable:FlushMemTableFinished");
return s;
}
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
10 changes: 10 additions & 0 deletions db/memtable_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,13 @@ 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 +443,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 bb35552

Please sign in to comment.