diff options
author | Richard Samuels <richard.l.samuels@gmail.com> | 2021-10-29 14:43:44 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-10-29 15:21:28 +0000 |
commit | e8aafb99f494c29e6ed05e3696a9cd2bb6b3ea5b (patch) | |
tree | 18ffacd0be9ce091a11a87fe2b7f3d8398beb9f0 | |
parent | 573525802dd48e94453fa4b9168dd9505f9dc93a (diff) | |
download | mongo-e8aafb99f494c29e6ed05e3696a9cd2bb6b3ea5b.tar.gz |
SERVER-61096 ResetDbPath sometimes errors while recreating dbpath on Windows
-rw-r--r-- | src/mongo/shell/shell_utils_launcher.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/mongo/shell/shell_utils_launcher.cpp b/src/mongo/shell/shell_utils_launcher.cpp index 8a01b448d03..eb0637fb031 100644 --- a/src/mongo/shell/shell_utils_launcher.cpp +++ b/src/mongo/shell/shell_utils_launcher.cpp @@ -908,6 +908,8 @@ BSONObj ResetDbpath(const BSONObj& a, void* data) { boost::filesystem::remove_all(path); } catch (const boost::filesystem::filesystem_error&) { #ifdef _WIN32 + // A small sleep allows Windows an opportunity to close locked file + // handlers, and reduce false errors on remove_all sleepmillis(100); boost::filesystem::remove_all(path); #else @@ -915,7 +917,18 @@ BSONObj ResetDbpath(const BSONObj& a, void* data) { #endif } } - boost::filesystem::create_directory(path); + try { + boost::filesystem::create_directory(path); + } catch (const boost::filesystem::filesystem_error&) { +#ifdef _WIN32 + // A small sleep allows Windows an opportunity to close locked file + // handlers, and reduce false errors on create_directory + sleepmillis(100); + boost::filesystem::create_directory(path); +#else + throw; +#endif + } return undefinedReturn; } |