diff --git a/db/db_impl.cc b/db/db_impl.cc index 2f38d3da0..3557d3691 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -2393,17 +2393,19 @@ Status DBImpl::EnableAutoCompaction( const std::vector& column_family_handles) { Status s; for (auto cf_ptr : column_family_handles) { - // check options here, enable only if didn't initially disable - if (s.ok()) { - s = this->SetOptions(cf_ptr, {{"disable_auto_compactions", "false"}}); + Status status = + this->SetOptions(cf_ptr, {{"disable_auto_compactions", "false"}}); + if (status.ok()) { + ColumnFamilyData* cfd = + reinterpret_cast(cf_ptr)->cfd(); + InstrumentedMutexLock guard_lock(&mutex_); + delete this->InstallSuperVersionAndScheduleWork( + cfd, nullptr, *cfd->GetLatestMutableCFOptions()); + } else { + s = status; } } - if (s.ok()) { - InstrumentedMutexLock guard_lock(&mutex_); - MaybeScheduleFlushOrCompaction(); - } - return s; } diff --git a/include/rocksdb/db.h b/include/rocksdb/db.h index 2fb1c51b5..eeb31f924 100644 --- a/include/rocksdb/db.h +++ b/include/rocksdb/db.h @@ -559,8 +559,14 @@ class DB { virtual Status ContinueBackgroundWork() = 0; // This function will enable automatic compactions for the given column - // families if they were previously disabled via the disable_auto_compactions - // option. + // families if they were previously disabled. The function will first set the + // disable_auto_compactions option for each column family to 'false', after + // which it will schedule a flush/compaction. + // + // NOTE: Setting disable_auto_compactions to 'false' through SetOptions() API + // does NOT schedule a flush/compaction afterwards, and only changes the + // parameter itself within the column family option. + // virtual Status EnableAutoCompaction( const std::vector& column_family_handles) = 0;