diff --git a/db/db_impl.cc b/db/db_impl.cc index f96d245..68da78a 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -231,12 +231,18 @@ void DBImpl::RemoveObsoleteFiles() { return; } + std::vector filenames; + // Dealing with many thousand file can make getting children very slow. + // All file numbers are incremental, so any file produced concurrently + // will have same or greater Number. + mutex_.Unlock(); + env_->GetChildren(dbname_, &filenames); // Ignoring errors on purpose + mutex_.Lock(); + // Make a set of all of the live files std::set live = pending_outputs_; versions_->AddLiveFiles(&live); - std::vector filenames; - env_->GetChildren(dbname_, &filenames); // Ignoring errors on purpose uint64_t number; FileType type; std::vector files_to_delete;