diff options
author | Gabriel Russell <gabriel.russell@mongodb.com> | 2020-11-09 14:25:21 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-11-23 18:20:20 +0000 |
commit | 35fa4e01778f93a5ece635307a5bba04c6648f3f (patch) | |
tree | ff4b6b9ab79061a863368c90eec58f6d962ac34a | |
parent | 8bc84de690e1de3cf2755032ac165fc4a3211441 (diff) | |
download | mongo-35fa4e01778f93a5ece635307a5bba04c6648f3f.tar.gz |
SERVER-50891 alow opCtx's to be created without globalStorageEngines
o It's required that one be able to create opCtx's without
globalStorageEngines. When the globalStorageEngine fails to get properly
initialized, the process will shutdown. Shutdown tasks will then need to
be able to create and use opCtx's
-rw-r--r-- | src/mongo/db/operation_context.h | 2 | ||||
-rw-r--r-- | src/mongo/db/service_context_d.cpp | 17 |
2 files changed, 10 insertions, 9 deletions
diff --git a/src/mongo/db/operation_context.h b/src/mongo/db/operation_context.h index 57a1c12c584..cbd2d3e943b 100644 --- a/src/mongo/db/operation_context.h +++ b/src/mongo/db/operation_context.h @@ -94,6 +94,7 @@ public: * Interface for durability. Caller DOES NOT own pointer. */ RecoveryUnit* recoveryUnit() const { + invariant(_recoveryUnit); return _recoveryUnit.get(); } @@ -123,6 +124,7 @@ public: * Interface for locking. Caller DOES NOT own pointer. */ Locker* lockState() const { + invariant(_locker); return _locker.get(); } diff --git a/src/mongo/db/service_context_d.cpp b/src/mongo/db/service_context_d.cpp index 7fbb189194d..8d70cff7667 100644 --- a/src/mongo/db/service_context_d.cpp +++ b/src/mongo/db/service_context_d.cpp @@ -268,17 +268,16 @@ std::unique_ptr<OperationContext> ServiceContextMongoD::_newOpCtx(Client* client invariant(&cc() == client); auto opCtx = stdx::make_unique<OperationContext>(client, opId); - auto globalStorageEngine = getGlobalStorageEngine(); - invariant(globalStorageEngine); + if (auto globalStorageEngine = getGlobalStorageEngine()) { + if (globalStorageEngine->isMmapV1()) { + opCtx->setLockState(stdx::make_unique<MMAPV1LockerImpl>()); + } else { + opCtx->setLockState(stdx::make_unique<DefaultLockerImpl>()); + } - if (globalStorageEngine->isMmapV1()) { - opCtx->setLockState(stdx::make_unique<MMAPV1LockerImpl>()); - } else { - opCtx->setLockState(stdx::make_unique<DefaultLockerImpl>()); + opCtx->setRecoveryUnit(globalStorageEngine->newRecoveryUnit(), + OperationContext::kNotInUnitOfWork); } - - opCtx->setRecoveryUnit(globalStorageEngine->newRecoveryUnit(), - OperationContext::kNotInUnitOfWork); return opCtx; } |