From d5de22dc099311b59a9e3d735702b6b9f18c7855 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Mon, 10 Mar 2014 15:42:14 -0700 Subject: [PATCH] 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 --- db/db_impl.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/db/db_impl.cc b/db/db_impl.cc index 2e8d00686..65e8e437c 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -361,7 +361,9 @@ DBImpl::~DBImpl() { FindObsoleteFiles(deletion_state, true); // manifest number starting from 2 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(); DeletionState deletion_state; FindObsoleteFiles(deletion_state, true); - PurgeObsoleteFiles(deletion_state); + if (deletion_state.HaveSomethingToDelete()) { + PurgeObsoleteFiles(deletion_state); + } } // 1. Go through all archived files and @@ -2782,7 +2786,9 @@ static void CleanupIteratorState(void* arg1, void* arg2) { state->mu->Unlock(); delete state->super_version; - state->db->PurgeObsoleteFiles(deletion_state); + if (deletion_state.HaveSomethingToDelete()) { + state->db->PurgeObsoleteFiles(deletion_state); + } } delete state; @@ -3759,7 +3765,9 @@ Status DBImpl::DeleteFile(std::string name) { } // lock released here LogFlush(options_.info_log); // remove files outside the db-lock - PurgeObsoleteFiles(deletion_state); + if (deletion_state.HaveSomethingToDelete()) { + PurgeObsoleteFiles(deletion_state); + } { MutexLock l(&mutex_); // schedule flush if file deletion means we freed the space for flushes to