Skip to content

Commit bb35552

Browse files
authored
PLAT-7494: rocksdb stall on manual Flush() and CompactRange() (#57)
1 parent d6214b7 commit bb35552

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

db/db_impl/db_impl_compaction_flush.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,6 +1989,10 @@ Status DBImpl::FlushMemTable(ColumnFamilyData* cfd,
19891989
}
19901990
}
19911991

1992+
if (flush_reason == FlushReason::kManualCompaction ||
1993+
flush_reason == FlushReason::kManualFlush) {
1994+
cfd->imm()->BeginManualOperation();
1995+
}
19921996
autovector<FlushRequest> flush_reqs;
19931997
autovector<uint64_t> memtable_ids_to_wait;
19941998
{
@@ -2107,6 +2111,10 @@ Status DBImpl::FlushMemTable(ColumnFamilyData* cfd,
21072111
tmp_cfd->UnrefAndTryDelete();
21082112
}
21092113
}
2114+
if (flush_reason == FlushReason::kManualCompaction ||
2115+
flush_reason == FlushReason::kManualFlush) {
2116+
cfd->imm()->CompleteManualOperation();
2117+
}
21102118
TEST_SYNC_POINT("DBImpl::FlushMemTable:FlushMemTableFinished");
21112119
return s;
21122120
}

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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,13 @@ 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+
};
400+
394401
private:
395402
friend Status InstallMemtableAtomicFlushResults(
396403
const autovector<MemTableList*>* imm_lists,
@@ -436,6 +443,9 @@ class MemTableList {
436443

437444
// Cached value of current_->HasHistory().
438445
std::atomic<bool> current_has_history_;
446+
447+
// count of manual flush/compactions active
448+
std::atomic<int> active_manuals_{0};
439449
};
440450

441451
// Installs memtable atomic flush results.

0 commit comments

Comments
 (0)