mirror of
https://github.com/google/leveldb.git
synced 2025-02-04 07:10:10 +08:00
Release lock when listing files in deleteObsoleteFiles
In some cases the number number of files in DB directory can be very high, so GetChildren can be very slow to compute. Releasing the lock during this operation enable more concurrent read/write.
This commit is contained in:
parent
53e280b568
commit
ac7e34137c
@ -229,12 +229,18 @@ void DBImpl::DeleteObsoleteFiles() {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string> 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<uint64_t> live = pending_outputs_;
|
||||
versions_->AddLiveFiles(&live);
|
||||
|
||||
std::vector<std::string> filenames;
|
||||
env_->GetChildren(dbname_, &filenames); // Ignoring errors on purpose
|
||||
uint64_t number;
|
||||
FileType type;
|
||||
std::vector<std::string> files_to_delete;
|
||||
|
Loading…
Reference in New Issue
Block a user