// Job id == 0 means that this is not our background process, but rather
// user thread
JobContext job_context(0);
- bool should_purge_files = false;
+ bool file_deletion_enabled = false;
{
InstrumentedMutexLock l(&mutex_);
if (force) {
--disable_delete_obsolete_files_;
}
if (disable_delete_obsolete_files_ == 0) {
- ROCKS_LOG_INFO(immutable_db_options_.info_log, "File Deletions Enabled");
- should_purge_files = true;
+ file_deletion_enabled = true;
FindObsoleteFiles(&job_context, true);
bg_cv_.SignalAll();
- } else {
- ROCKS_LOG_WARN(
- immutable_db_options_.info_log,
- "File Deletions Enable, but not really enabled. Counter: %d",
- disable_delete_obsolete_files_);
}
}
- if (should_purge_files) {
+ if (file_deletion_enabled) {
+ ROCKS_LOG_INFO(immutable_db_options_.info_log, "File Deletions Enabled");
PurgeObsoleteFiles(job_context);
+ } else {
+ ROCKS_LOG_WARN(immutable_db_options_.info_log,
+ "File Deletions Enable, but not really enabled. Counter: %d",
+ disable_delete_obsolete_files_);
}
job_context.Clean();
LogFlush(immutable_db_options_.info_log);
if (flush_memtable) {
// flush all dirty data to disk.
Status status;
- for (auto cfd : *versions_->GetColumnFamilySet()) {
- if (cfd->IsDropped()) {
- continue;
- }
- cfd->Ref();
+ if (immutable_db_options_.atomic_flush) {
+ autovector<ColumnFamilyData*> cfds;
+ SelectColumnFamiliesForAtomicFlush(&cfds);
mutex_.Unlock();
- status = FlushMemTable(cfd, FlushOptions(), FlushReason::kGetLiveFiles);
- TEST_SYNC_POINT("DBImpl::GetLiveFiles:1");
- TEST_SYNC_POINT("DBImpl::GetLiveFiles:2");
+ status = AtomicFlushMemTables(cfds, FlushOptions(),
+ FlushReason::kGetLiveFiles);
mutex_.Lock();
- cfd->Unref();
- if (!status.ok()) {
- break;
+ } else {
+ for (auto cfd : *versions_->GetColumnFamilySet()) {
+ if (cfd->IsDropped()) {
+ continue;
+ }
+ cfd->Ref();
+ mutex_.Unlock();
+ status = FlushMemTable(cfd, FlushOptions(), FlushReason::kGetLiveFiles);
+ TEST_SYNC_POINT("DBImpl::GetLiveFiles:1");
+ TEST_SYNC_POINT("DBImpl::GetLiveFiles:2");
+ mutex_.Lock();
+ cfd->Unref();
+ if (!status.ok()) {
+ break;
+ }
}
}
versions_->GetColumnFamilySet()->FreeDeadColumnFamilies();
// create names of the live files. The names are not absolute
// paths, instead they are relative to dbname_;
- for (auto live_file : live) {
+ for (const auto& live_file : live) {
ret.push_back(MakeTableFileName("", live_file.GetNumber()));
}