summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2018-06-11 16:01:14 -0400
committerHenrik Edin <henrik.edin@mongodb.com>2018-06-13 16:04:01 -0400
commit85477a157ab217912eec55422a9d7b2d0e7b0d47 (patch)
tree7ecb7d7c1d6cf5e1993eb63e5c38233e37476b6e /src/mongo
parent3c6d6969752ad4322594dab171ca7dd26b854bc8 (diff)
downloadmongo-85477a157ab217912eec55422a9d7b2d0e7b0d47.tar.gz
SERVER-34762 Remove lock file on embedded.
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/db.cpp2
-rw-r--r--src/mongo/db/service_context_d_test_fixture.cpp2
-rw-r--r--src/mongo/db/service_context_devnull_test_fixture.cpp2
-rw-r--r--src/mongo/db/storage/storage_engine_init.cpp5
-rw-r--r--src/mongo/db/storage/storage_engine_init.h13
-rw-r--r--src/mongo/dbtests/framework.cpp2
-rw-r--r--src/mongo/embedded/embedded.cpp4
-rw-r--r--src/mongo/platform/bitwise_enum_operators.h14
8 files changed, 27 insertions, 17 deletions
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp
index ae850fadeab..ea2fd75bb51 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -339,7 +339,7 @@ ExitCode _initAndListen(int listenPort) {
serviceContext->setTransportLayer(std::move(tl));
}
- initializeStorageEngine(serviceContext);
+ initializeStorageEngine(serviceContext, StorageEngineInitFlags::kNone);
#ifdef MONGO_CONFIG_WIREDTIGER_ENABLED
if (EncryptionHooks::get(serviceContext)->restartRequired()) {
diff --git a/src/mongo/db/service_context_d_test_fixture.cpp b/src/mongo/db/service_context_d_test_fixture.cpp
index db0b6bbee7b..ae0e39a2ab4 100644
--- a/src/mongo/db/service_context_d_test_fixture.cpp
+++ b/src/mongo/db/service_context_d_test_fixture.cpp
@@ -69,7 +69,7 @@ void ServiceContextMongoDTest::setUp() {
storageGlobalParams.engineSetByUser = true;
createLockFile(serviceContext);
- initializeStorageEngine(serviceContext);
+ initializeStorageEngine(serviceContext, StorageEngineInitFlags::kNone);
serviceContext->setOpObserver(stdx::make_unique<OpObserverNoop>());
}
diff --git a/src/mongo/db/service_context_devnull_test_fixture.cpp b/src/mongo/db/service_context_devnull_test_fixture.cpp
index cefea8a0053..e3d47823733 100644
--- a/src/mongo/db/service_context_devnull_test_fixture.cpp
+++ b/src/mongo/db/service_context_devnull_test_fixture.cpp
@@ -54,7 +54,7 @@ void ServiceContextDevnullTestFixture::setUp() {
mongo::storageGlobalParams.engine = "devnull";
mongo::storageGlobalParams.engineSetByUser = true;
createLockFile(serviceContext);
- initializeStorageEngine(serviceContext);
+ initializeStorageEngine(serviceContext, StorageEngineInitFlags::kNone);
}
}
diff --git a/src/mongo/db/storage/storage_engine_init.cpp b/src/mongo/db/storage/storage_engine_init.cpp
index 24a0b790972..d69673679fb 100644
--- a/src/mongo/db/storage/storage_engine_init.cpp
+++ b/src/mongo/db/storage/storage_engine_init.cpp
@@ -47,14 +47,15 @@ namespace mongo {
extern bool _supportsDocLocking;
-void initializeStorageEngine(ServiceContext* service) {
+void initializeStorageEngine(ServiceContext* service, StorageEngineInitFlags initFlags) {
// This should be set once.
invariant(!service->getStorageEngine());
// We should have a lock file or be in read-only mode. Confusingly, we can still have a lockFile
// if we are in read-only mode. This can happen if the server is started in read-only mode on a
// writable dbpath.
- invariant(StorageEngineLockFile::get(service) || storageGlobalParams.readOnly);
+ invariant((initFlags & StorageEngineInitFlags::kAllowNoLockFile) ||
+ StorageEngineLockFile::get(service) || storageGlobalParams.readOnly);
const std::string dbpath = storageGlobalParams.dbpath;
if (auto existingStorageEngine = StorageEngineMetadata::getStorageEngineForPath(dbpath)) {
diff --git a/src/mongo/db/storage/storage_engine_init.h b/src/mongo/db/storage/storage_engine_init.h
index 161cc4558b9..1cf30ff43ad 100644
--- a/src/mongo/db/storage/storage_engine_init.h
+++ b/src/mongo/db/storage/storage_engine_init.h
@@ -33,13 +33,22 @@
#include "mongo/base/string_data.h"
#include "mongo/db/service_context.h"
#include "mongo/db/storage/storage_engine.h"
+#include "mongo/platform/bitwise_enum_operators.h"
namespace mongo {
/**
+ * Valid flags to pass to initializeStorageEngine. Used as a bitfield.
+ */
+enum StorageEngineInitFlags {
+ kNone = 0,
+ kAllowNoLockFile = 1 << 0,
+};
+
+/**
* Initializes the storage engine on "service".
*/
-void initializeStorageEngine(ServiceContext* service);
+void initializeStorageEngine(ServiceContext* service, StorageEngineInitFlags initFlags);
/**
* Shuts down storage engine cleanly and releases any locks on mongod.lock.
@@ -90,4 +99,6 @@ Status validateStorageOptions(
*/
void appendStorageEngineList(ServiceContext* service, BSONObjBuilder* result);
+ENABLE_BITMASK_OPERATORS(StorageEngineInitFlags)
+
} // namespace mongo
diff --git a/src/mongo/dbtests/framework.cpp b/src/mongo/dbtests/framework.cpp
index 99ca486921d..0a9d923eb4e 100644
--- a/src/mongo/dbtests/framework.cpp
+++ b/src/mongo/dbtests/framework.cpp
@@ -91,7 +91,7 @@ int runDbTests(int argc, char** argv) {
srand((unsigned)frameworkGlobalParams.seed);
createLockFile(globalServiceContext);
- initializeStorageEngine(globalServiceContext);
+ initializeStorageEngine(globalServiceContext, StorageEngineInitFlags::kNone);
auto registry = stdx::make_unique<OpObserverRegistry>();
registry->addObserver(stdx::make_unique<UUIDCatalogObserver>());
globalServiceContext->setOpObserver(std::move(registry));
diff --git a/src/mongo/embedded/embedded.cpp b/src/mongo/embedded/embedded.cpp
index 330cd33c249..a548a6922e2 100644
--- a/src/mongo/embedded/embedded.cpp
+++ b/src/mongo/embedded/embedded.cpp
@@ -210,9 +210,7 @@ ServiceContext* initialize(const char* yaml_config) {
DEV log(LogComponent::kControl) << "DEBUG build (which is slower)" << endl;
- createLockFile(serviceContext);
-
- initializeStorageEngine(serviceContext);
+ initializeStorageEngine(serviceContext, StorageEngineInitFlags::kAllowNoLockFile);
// Warn if we detect configurations for multiple registered storage engines in the same
// configuration file/environment.
diff --git a/src/mongo/platform/bitwise_enum_operators.h b/src/mongo/platform/bitwise_enum_operators.h
index 8647f5e8a43..c41e9a40c08 100644
--- a/src/mongo/platform/bitwise_enum_operators.h
+++ b/src/mongo/platform/bitwise_enum_operators.h
@@ -89,11 +89,11 @@ typename std::enable_if<EnableBitMaskOperators<Enum>::enable, Enum&>::type opera
} // namespace mongo
-#define ENABLE_BITMASK_OPERATORS(x) \
- \
- template <> \
- \
- struct EnableBitMaskOperators<x> { \
- static_assert(std::is_enum<typename x>::value, "template parameter is not an enum type"); \
- static const bool enable = true; \
+#define ENABLE_BITMASK_OPERATORS(x) \
+ \
+ template <> \
+ \
+ struct EnableBitMaskOperators<x> { \
+ static_assert(std::is_enum<x>::value, "template parameter is not an enum type"); \
+ static const bool enable = true; \
};