From 94e139f94d97628cfd633d32bbad8185d2f8add4 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Mon, 11 Nov 2013 21:03:41 -0800 Subject: [PATCH] Fixing failed delete file test Summary: FindObsoleteFiles() has to be called before PurgeObsoleteFiles() because FindObsoleteFiles() sets manifest_file_number, log_number and prev_log_number to valid values. Test Plan: deletefile_test now works Reviewers: dhruba, emayanke, kailiu Reviewed By: kailiu CC: leveldb Differential Revision: https://reviews.facebook.net/D13995 --- db/db_impl.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/db/db_impl.cc b/db/db_impl.cc index 4eef17495..0e16afc5f 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -1627,12 +1627,13 @@ void DBImpl::BackgroundCallFlush() { LogFlush(options_.info_log); env_->SleepForMicroseconds(1000000); mutex_.Lock(); - // clean up all the files we might have created + // clean up all the files we might have created. FindObsoleteFiles(deletion_state, true); } } // delete unnecessary files if any, this is done outside the mutex + FindObsoleteFiles(deletion_state, false); if (deletion_state.HaveSomethingToDelete()) { mutex_.Unlock(); PurgeObsoleteFiles(deletion_state); @@ -1680,6 +1681,7 @@ void DBImpl::BackgroundCallCompaction() { } // delete unnecessary files if any, this is done outside the mutex + FindObsoleteFiles(deletion_state, false); if (deletion_state.HaveSomethingToDelete()) { mutex_.Unlock(); PurgeObsoleteFiles(deletion_state); @@ -1771,7 +1773,6 @@ Status DBImpl::BackgroundCompaction(bool* madeProgress, versions_->ReleaseCompactionFiles(c.get(), status); c->ReleaseInputs(); versions_->GetAndFreeObsoleteFiles(&deletion_state.sstdeletefiles); - FindObsoleteFiles(deletion_state, false); *madeProgress = true; } c.reset(); @@ -3363,6 +3364,7 @@ Status DBImpl::DeleteFile(std::string name) { if (status.ok()) { versions_->GetAndFreeObsoleteFiles(&deletion_state.sstdeletefiles); } + FindObsoleteFiles(deletion_state, false); } // lock released here LogFlush(options_.info_log);