Call PurgeObsoleteFiles() only when HaveSomethingToDelete()

Summary: as title

Test Plan: fixed the build failure http://ci-builds.fb.com/job/rocksdb_build/987/console

Reviewers: haobo

Reviewed By: haobo

CC: leveldb

Differential Revision: https://reviews.facebook.net/D16743
This commit is contained in:
Igor Canadi 2014-03-10 15:42:14 -07:00
parent 9db8c4c556
commit d5de22dc09

View File

@ -361,7 +361,9 @@ DBImpl::~DBImpl() {
FindObsoleteFiles(deletion_state, true); FindObsoleteFiles(deletion_state, true);
// manifest number starting from 2 // manifest number starting from 2
deletion_state.manifest_file_number = 1; deletion_state.manifest_file_number = 1;
PurgeObsoleteFiles(deletion_state); if (deletion_state.HaveSomethingToDelete()) {
PurgeObsoleteFiles(deletion_state);
}
} }
} }
@ -780,7 +782,9 @@ void DBImpl::DeleteObsoleteFiles() {
mutex_.AssertHeld(); mutex_.AssertHeld();
DeletionState deletion_state; DeletionState deletion_state;
FindObsoleteFiles(deletion_state, true); FindObsoleteFiles(deletion_state, true);
PurgeObsoleteFiles(deletion_state); if (deletion_state.HaveSomethingToDelete()) {
PurgeObsoleteFiles(deletion_state);
}
} }
// 1. Go through all archived files and // 1. Go through all archived files and
@ -2782,7 +2786,9 @@ static void CleanupIteratorState(void* arg1, void* arg2) {
state->mu->Unlock(); state->mu->Unlock();
delete state->super_version; delete state->super_version;
state->db->PurgeObsoleteFiles(deletion_state); if (deletion_state.HaveSomethingToDelete()) {
state->db->PurgeObsoleteFiles(deletion_state);
}
} }
delete state; delete state;
@ -3759,7 +3765,9 @@ Status DBImpl::DeleteFile(std::string name) {
} // lock released here } // lock released here
LogFlush(options_.info_log); LogFlush(options_.info_log);
// remove files outside the db-lock // remove files outside the db-lock
PurgeObsoleteFiles(deletion_state); if (deletion_state.HaveSomethingToDelete()) {
PurgeObsoleteFiles(deletion_state);
}
{ {
MutexLock l(&mutex_); MutexLock l(&mutex_);
// schedule flush if file deletion means we freed the space for flushes to // schedule flush if file deletion means we freed the space for flushes to