Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLAT-7494: rocksdb stall on manual Flush() and CompactRange() #57

Merged
merged 3 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading