diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2020-04-24 14:16:31 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-05-01 15:41:43 +0000 |
commit | 86c5888a258476d3c04a8d360685635b96ff9a4f (patch) | |
tree | 8bd38c518f8775de4707837c9fc37e0340c573e5 | |
parent | 33fc1326ee16fdf01aab21098697551f60fd05bb (diff) | |
download | mongo-86c5888a258476d3c04a8d360685635b96ff9a4f.tar.gz |
SERVER-46398 Expand the data directory not found message on startup to be more informative
(cherry picked from commit 06755cd5a43d08b5e1e9163e060177d728ae6696)
4 files changed, 13 insertions, 4 deletions
diff --git a/src/mongo/db/storage/storage_engine_lock_file.cpp b/src/mongo/db/storage/storage_engine_lock_file.cpp index 1f68840e7f3..40fd1d302b4 100644 --- a/src/mongo/db/storage/storage_engine_lock_file.cpp +++ b/src/mongo/db/storage/storage_engine_lock_file.cpp @@ -34,6 +34,8 @@ #include "mongo/db/storage/storage_engine_lock_file.h" +#include "mongo/util/str.h" + namespace mongo { namespace { @@ -45,4 +47,11 @@ boost::optional<StorageEngineLockFile>& StorageEngineLockFile::get(ServiceContex return getLockFile(service); } +std::string StorageEngineLockFile::_getNonExistentPathMessage() const { + return str::stream() << "Data directory " << _dbpath + << " not found. Create the missing directory or specify another path " + "using (1) the --dbpath command line option, or (2) by adding the " + "'storage.dbPath' option in the configuration file."; +} + } // namespace mongo diff --git a/src/mongo/db/storage/storage_engine_lock_file.h b/src/mongo/db/storage/storage_engine_lock_file.h index b043dd6ed9b..5b1b0f38184 100644 --- a/src/mongo/db/storage/storage_engine_lock_file.h +++ b/src/mongo/db/storage/storage_engine_lock_file.h @@ -92,6 +92,8 @@ public: void clearPidAndUnlock(); private: + std::string _getNonExistentPathMessage() const; + std::string _dbpath; std::string _filespec; bool _uncleanShutdown; diff --git a/src/mongo/db/storage/storage_engine_lock_file_posix.cpp b/src/mongo/db/storage/storage_engine_lock_file_posix.cpp index e08764a4aa9..46a9d6246a6 100644 --- a/src/mongo/db/storage/storage_engine_lock_file_posix.cpp +++ b/src/mongo/db/storage/storage_engine_lock_file_posix.cpp @@ -130,8 +130,7 @@ bool StorageEngineLockFile::createdByUncleanShutdown() const { Status StorageEngineLockFile::open() { try { if (!boost::filesystem::exists(_dbpath)) { - return Status(ErrorCodes::NonExistentPath, - str::stream() << "Data directory " << _dbpath << " not found."); + return Status(ErrorCodes::NonExistentPath, _getNonExistentPathMessage()); } } catch (const std::exception& ex) { return Status(ErrorCodes::UnknownError, diff --git a/src/mongo/db/storage/storage_engine_lock_file_windows.cpp b/src/mongo/db/storage/storage_engine_lock_file_windows.cpp index 97bd280c3fe..b141044246d 100644 --- a/src/mongo/db/storage/storage_engine_lock_file_windows.cpp +++ b/src/mongo/db/storage/storage_engine_lock_file_windows.cpp @@ -104,8 +104,7 @@ bool StorageEngineLockFile::createdByUncleanShutdown() const { Status StorageEngineLockFile::open() { try { if (!boost::filesystem::exists(_dbpath)) { - return Status(ErrorCodes::NonExistentPath, - str::stream() << "Data directory " << _dbpath << " not found."); + return Status(ErrorCodes::NonExistentPath, _getNonExistentPathMessage()); } } catch (const std::exception& ex) { return Status(ErrorCodes::UnknownError, |