summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Noma <gregory.noma@gmail.com>2020-06-09 14:39:49 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-06-17 19:50:43 +0000
commit04594d981c0530baf5c56eb22e0c3e86d47c3bbb (patch)
tree90600a7c39689158d890992dbf4ec2b9e4d65fe4
parentdafcca3799f37f168fb6f967648850ef616585d8 (diff)
downloadmongo-04594d981c0530baf5c56eb22e0c3e86d47c3bbb.tar.gz
SERVER-44553 Make the shell ResetDbpath helper resilient to files being open on Windows
(cherry picked from commit c277251fb7bce31be749a236a07bdc7b3412b173)
-rw-r--r--src/mongo/shell/shell_utils_launcher.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/mongo/shell/shell_utils_launcher.cpp b/src/mongo/shell/shell_utils_launcher.cpp
index 8fcefa3e690..bf0e7644ec9 100644
--- a/src/mongo/shell/shell_utils_launcher.cpp
+++ b/src/mongo/shell/shell_utils_launcher.cpp
@@ -862,8 +862,18 @@ BSONObj ResetDbpath(const BSONObj& a, void* data) {
LOGV2_WARNING(22824, "ResetDbpath(): nothing to do, path was empty");
return undefinedReturn;
}
- if (boost::filesystem::exists(path))
- boost::filesystem::remove_all(path);
+ if (boost::filesystem::exists(path)) {
+ try {
+ boost::filesystem::remove_all(path);
+ } catch (const boost::filesystem::filesystem_error&) {
+#ifdef _WIN32
+ sleepmillis(100);
+ boost::filesystem::remove_all(path);
+#else
+ throw;
+#endif
+ }
+ }
boost::filesystem::create_directory(path);
return undefinedReturn;
}