Add comment to DisableManualCompaction() (#8186)

Summary:
Add comment to DisableManualCompaction() which was missing.
Also explictly return from DBImpl::CompactRange() to avoid memtable flush when manual compaction is disabled.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/8186

Test Plan: Run existing unit tests.

Reviewed By: jay-zhuang

Differential Revision: D27744517

fbshipit-source-id: 449548a48905903b888dc9612bd17480f6596a71
This commit is contained in:
sdong 2021-04-21 15:23:04 -07:00 committed by Facebook GitHub Bot
parent 596e9008e4
commit 4985cea141
2 changed files with 10 additions and 0 deletions

View File

@ -803,6 +803,10 @@ Status DBImpl::CompactRange(const CompactRangeOptions& options,
ColumnFamilyHandle* column_family,
const Slice* begin_without_ts,
const Slice* end_without_ts) {
if (manual_compaction_paused_.load(std::memory_order_acquire) > 0) {
return Status::Incomplete(Status::SubCode::kManualCompactionPaused);
}
const Comparator* const ucmp = column_family->GetComparator();
assert(ucmp);
size_t ts_sz = ucmp->timestamp_size();

View File

@ -1180,7 +1180,13 @@ class DB {
virtual Status EnableAutoCompaction(
const std::vector<ColumnFamilyHandle*>& column_family_handles) = 0;
// After this function call, CompactRange() or CompactFiles() will not
// run compactions and fail. The function will wait for all outstanding
// manual compactions to finish before returning
virtual void DisableManualCompaction() = 0;
// Re-enable CompactRange() and ComapctFiles() that are disabled by
// DisableManualCompaction(). In debug mode, it might hit assertion if
// no DisableManualCompaction() was previously called.
virtual void EnableManualCompaction() = 0;
// Number of levels used for this DB.