summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/db/service_context.cpp9
-rw-r--r--src/mongo/db/service_context_d.cpp7
2 files changed, 13 insertions, 3 deletions
diff --git a/src/mongo/db/service_context.cpp b/src/mongo/db/service_context.cpp
index 25c84c48882..719f2c2dadb 100644
--- a/src/mongo/db/service_context.cpp
+++ b/src/mongo/db/service_context.cpp
@@ -28,6 +28,8 @@
* it in the license file.
*/
+#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kDefault
+
#include "mongo/platform/basic.h"
#include "mongo/db/service_context.h"
@@ -41,6 +43,7 @@
#include "mongo/transport/session.h"
#include "mongo/transport/transport_layer.h"
#include "mongo/util/assert_util.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/system_clock_source.h"
#include "mongo/util/system_tick_source.h"
@@ -93,7 +96,11 @@ bool supportsDocLocking() {
bool isMMAPV1() {
StorageEngine* globalStorageEngine = getGlobalServiceContext()->getGlobalStorageEngine();
- invariant(globalStorageEngine);
+ if (!globalStorageEngine) {
+ warning()
+ << "Attempted to check if storage engine is MMAPv1 without an existing storage engine.";
+ return false;
+ }
return globalStorageEngine->isMmapV1();
}
diff --git a/src/mongo/db/service_context_d.cpp b/src/mongo/db/service_context_d.cpp
index d3be43d88ed..7fbb189194d 100644
--- a/src/mongo/db/service_context_d.cpp
+++ b/src/mongo/db/service_context_d.cpp
@@ -268,13 +268,16 @@ std::unique_ptr<OperationContext> ServiceContextMongoD::_newOpCtx(Client* client
invariant(&cc() == client);
auto opCtx = stdx::make_unique<OperationContext>(client, opId);
- if (isMMAPV1()) {
+ auto globalStorageEngine = getGlobalStorageEngine();
+ invariant(globalStorageEngine);
+
+ if (globalStorageEngine->isMmapV1()) {
opCtx->setLockState(stdx::make_unique<MMAPV1LockerImpl>());
} else {
opCtx->setLockState(stdx::make_unique<DefaultLockerImpl>());
}
- opCtx->setRecoveryUnit(getGlobalStorageEngine()->newRecoveryUnit(),
+ opCtx->setRecoveryUnit(globalStorageEngine->newRecoveryUnit(),
OperationContext::kNotInUnitOfWork);
return opCtx;
}