From 6d072f2a038d9e5f124f7674179b39aafc65a9ee Mon Sep 17 00:00:00 2001 From: Yanqin Jin Date: Tue, 17 Sep 2019 17:15:13 -0700 Subject: [PATCH] Move WAL-closing loop out of original loop (#5804) Summary: Originally the loop of closing WAL in PurgeObsoleteFiles resides inside a loop iterating over the candidate files. It should be moved out. Test plan (devserver) ``` $COMPILE_WITH_ASAN=1 make -j32 all $make check ``` Pull Request resolved: https://github.com/facebook/rocksdb/pull/5804 Differential Revision: D17374350 Pulled By: riversand963 fbshipit-source-id: 2bee7343fc0481d9a385a87c7676491522285c96 --- db/db_impl/db_impl_files.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/db/db_impl/db_impl_files.cc b/db/db_impl/db_impl_files.cc index 670d8e731..1fa288406 100644 --- a/db/db_impl/db_impl_files.cc +++ b/db/db_impl/db_impl_files.cc @@ -379,6 +379,12 @@ void DBImpl::PurgeObsoleteFiles(JobContext& state, bool schedule_only) { } } + // Close WALs before trying to delete them. + for (const auto w : state.logs_to_free) { + // TODO: maybe check the return value of Close. + w->Close(); + } + std::unordered_set files_to_del; for (const auto& candidate_file : candidate_files) { const std::string& to_delete = candidate_file.file_name; @@ -478,11 +484,6 @@ void DBImpl::PurgeObsoleteFiles(JobContext& state, bool schedule_only) { } #endif // !ROCKSDB_LITE - for (const auto w : state.logs_to_free) { - // TODO: maybe check the return value of Close. - w->Close(); - } - Status file_deletion_status; if (schedule_only) { InstrumentedMutexLock guard_lock(&mutex_);