From 5138764eb584ed1fb15bfa2ef2907ec4c476df21 Mon Sep 17 00:00:00 2001 From: Huisheng Liu Date: Thu, 13 Feb 2020 11:19:39 -0800 Subject: [PATCH] Fix destroydb (#6308) Summary: It's observed on Windows DestroyDB failed to remove the log file because the logger is still alive in sst file manager and holding a handle to the log file. This fix makes sure the logger is released before attempt to clear the database directory. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6308 Differential Revision: D19818829 Pulled By: riversand963 fbshipit-source-id: 54c3e6859aadaaba4a49b3e851b73dc35ec7dc6a --- db/db_impl/db_impl.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/db/db_impl/db_impl.cc b/db/db_impl/db_impl.cc index be204e64c..404fd215d 100644 --- a/db/db_impl/db_impl.cc +++ b/db/db_impl/db_impl.cc @@ -3591,6 +3591,11 @@ Status DestroyDB(const std::string& dbname, const Options& options, env->UnlockFile(lock); // Ignore error since state is already gone env->DeleteFile(lockname); + + // sst_file_manager holds a ref to the logger. Make sure the logger is + // gone before trying to remove the directory. + soptions.sst_file_manager.reset(); + env->DeleteDir(dbname); // Ignore error in case dir contains other files } return result;