|
@ -229,12 +229,19 @@ void DBImpl::DeleteObsoleteFiles() { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const uint64_t log_number = versions_->LogNumber(); |
|
|
|
|
|
const uint64_t prev_log_number = versions_->PrevLogNumber(); |
|
|
|
|
|
const uint64_t manifest_file_number = versions_->ManifestFileNumber(); |
|
|
|
|
|
|
|
|
// Make a set of all of the live files
|
|
|
// Make a set of all of the live files
|
|
|
std::set<uint64_t> live = pending_outputs_; |
|
|
std::set<uint64_t> live = pending_outputs_; |
|
|
versions_->AddLiveFiles(&live); |
|
|
versions_->AddLiveFiles(&live); |
|
|
|
|
|
|
|
|
std::vector<std::string> filenames; |
|
|
std::vector<std::string> filenames; |
|
|
env_->GetChildren(dbname_, &filenames); // Ignoring errors on purpose
|
|
|
env_->GetChildren(dbname_, &filenames); // Ignoring errors on purpose
|
|
|
|
|
|
|
|
|
|
|
|
// Unlock while deleting obsolete files
|
|
|
|
|
|
mutex_.Unlock(); |
|
|
uint64_t number; |
|
|
uint64_t number; |
|
|
FileType type; |
|
|
FileType type; |
|
|
for (size_t i = 0; i < filenames.size(); i++) { |
|
|
for (size_t i = 0; i < filenames.size(); i++) { |
|
@ -242,13 +249,12 @@ void DBImpl::DeleteObsoleteFiles() { |
|
|
bool keep = true; |
|
|
bool keep = true; |
|
|
switch (type) { |
|
|
switch (type) { |
|
|
case kLogFile: |
|
|
case kLogFile: |
|
|
keep = ((number >= versions_->LogNumber()) || |
|
|
|
|
|
(number == versions_->PrevLogNumber())); |
|
|
|
|
|
|
|
|
keep = ((number >= log_number) || (number == prev_log_number)); |
|
|
break; |
|
|
break; |
|
|
case kDescriptorFile: |
|
|
case kDescriptorFile: |
|
|
// Keep my manifest file, and any newer incarnations'
|
|
|
// Keep my manifest file, and any newer incarnations'
|
|
|
// (in case there is a race that allows other incarnations)
|
|
|
// (in case there is a race that allows other incarnations)
|
|
|
keep = (number >= versions_->ManifestFileNumber()); |
|
|
|
|
|
|
|
|
keep = (number >= manifest_file_number); |
|
|
break; |
|
|
break; |
|
|
case kTableFile: |
|
|
case kTableFile: |
|
|
keep = (live.find(number) != live.end()); |
|
|
keep = (live.find(number) != live.end()); |
|
@ -275,6 +281,7 @@ void DBImpl::DeleteObsoleteFiles() { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
mutex_.Lock(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Status DBImpl::Recover(VersionEdit* edit, bool* save_manifest) { |
|
|
Status DBImpl::Recover(VersionEdit* edit, bool* save_manifest) { |
|
|