diff options
author | Adam Midvidy <amidvidy@gmail.com> | 2016-01-12 10:56:32 -0500 |
---|---|---|
committer | Adam Midvidy <amidvidy@gmail.com> | 2016-01-13 13:03:41 -0500 |
commit | c125a557ccc5d452f3b31c3fd025bb07fe355468 (patch) | |
tree | c9891949daf7520ea777961bed79282ae2be21ae /src/mongo/db/service_context_d.cpp | |
parent | c2edffac9d7da55422e56213076fabdfbd8e7bb1 (diff) | |
download | mongo-c125a557ccc5d452f3b31c3fd025bb07fe355468.tar.gz |
SERVER-21197 check for existence of lock file prior to opening sockets
Diffstat (limited to 'src/mongo/db/service_context_d.cpp')
-rw-r--r-- | src/mongo/db/service_context_d.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/mongo/db/service_context_d.cpp b/src/mongo/db/service_context_d.cpp index 470dcb927a5..aa3a0181165 100644 --- a/src/mongo/db/service_context_d.cpp +++ b/src/mongo/db/service_context_d.cpp @@ -75,6 +75,22 @@ StorageEngine* ServiceContextMongoD::getGlobalStorageEngine() { extern bool _supportsDocLocking; +void ServiceContextMongoD::createLockFile() { + try { + _lockFile.reset(new StorageEngineLockFile(storageGlobalParams.dbpath)); + } catch (const std::exception& ex) { + uassert(28596, + str::stream() << "Unable to determine status of lock file in the data directory " + << storageGlobalParams.dbpath << ": " << ex.what(), + false); + } + bool wasUnclean = _lockFile->createdByUncleanShutdown(); + uassertStatusOK(_lockFile->open()); + if (wasUnclean) { + warning() << "Detected unclean shutdown - " << _lockFile->getFilespec() << " is not empty."; + } +} + void ServiceContextMongoD::initializeGlobalStorageEngine() { // This should be set once. invariant(!_storageEngine); @@ -131,19 +147,7 @@ void ServiceContextMongoD::initializeGlobalStorageEngine() { uassertStatusOK(factory->validateMetadata(*metadata, storageGlobalParams)); } - try { - _lockFile.reset(new StorageEngineLockFile(storageGlobalParams.dbpath)); - } catch (const std::exception& ex) { - uassert(28596, - str::stream() << "Unable to determine status of lock file in the data directory " - << storageGlobalParams.dbpath << ": " << ex.what(), - false); - } - if (_lockFile->createdByUncleanShutdown()) { - warning() << "Detected unclean shutdown - " << _lockFile->getFilespec() << " is not empty."; - } - uassertStatusOK(_lockFile->open()); - + invariant(_lockFile); ScopeGuard guard = MakeGuard(&StorageEngineLockFile::close, _lockFile.get()); _storageEngine = factory->create(storageGlobalParams, *_lockFile); _storageEngine->finishInit(); |