diff options
author | Benety Goh <benety@mongodb.com> | 2022-08-24 07:04:40 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-08-24 12:23:08 +0000 |
commit | dbb9f3a2783be8581a91373dfb5de8eef66df656 (patch) | |
tree | 14600eb0ea481c454aa72a08fc01ed4e31b1b5c8 /src/mongo/db/repl/tenant_oplog_applier.cpp | |
parent | 3b63216fb7beabecb79d51b291f7f49ac1a8ba1c (diff) | |
download | mongo-dbb9f3a2783be8581a91373dfb5de8eef66df656.tar.gz |
SERVER-68215 check out mongod sessions through MongoDSessionCatalog
Diffstat (limited to 'src/mongo/db/repl/tenant_oplog_applier.cpp')
-rw-r--r-- | src/mongo/db/repl/tenant_oplog_applier.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/mongo/db/repl/tenant_oplog_applier.cpp b/src/mongo/db/repl/tenant_oplog_applier.cpp index 098439436ee..7dac5595470 100644 --- a/src/mongo/db/repl/tenant_oplog_applier.cpp +++ b/src/mongo/db/repl/tenant_oplog_applier.cpp @@ -552,7 +552,7 @@ void TenantOplogApplier::_writeSessionNoOpsForRange( // All the ops will have the same session, so we can retain the scopedSession throughout // the loop, except when invalidated by multi-document transactions. This allows us to // track the statements in a retryable write. - boost::optional<MongoDOperationContextSessionWithoutOplogRead> scopedSession; + std::unique_ptr<MongoDSessionCatalog::Session> scopedSession; // Make sure a partial session doesn't escape. ON_BLOCK_EXIT([this, &scopedSession, &opCtx] { @@ -606,8 +606,11 @@ void TenantOplogApplier::_writeSessionNoOpsForRange( "op"_attr = redact(entry.toBSONForLogging())); // Check out the session. - if (!scopedSession) - scopedSession.emplace(opCtx.get()); + if (!scopedSession) { + auto mongoDSessionCatalog = MongoDSessionCatalog::get(opCtx.get()); + scopedSession = mongoDSessionCatalog->checkOutSessionWithoutOplogRead(opCtx.get()); + } + auto txnParticipant = TransactionParticipant::get(opCtx.get()); uassert( 5351500, @@ -750,8 +753,11 @@ void TenantOplogApplier::_writeSessionNoOpsForRange( opCtx->setLogicalSessionId(sessionId); opCtx->setTxnNumber(txnNumber); - if (!scopedSession) - scopedSession.emplace(opCtx.get()); + if (!scopedSession) { + auto mongoDSessionCatalog = MongoDSessionCatalog::get(opCtx.get()); + scopedSession = mongoDSessionCatalog->checkOutSessionWithoutOplogRead(opCtx.get()); + } + auto txnParticipant = TransactionParticipant::get(opCtx.get()); uassert(5350900, str::stream() << "Tenant oplog application failed to get retryable write " @@ -864,7 +870,7 @@ void TenantOplogApplier::_writeSessionNoOpsForRange( invariant(txnParticipant); txnParticipant.invalidate(opCtx.get()); opCtx->resetMultiDocumentTransactionState(); - scopedSession = boost::none; + scopedSession = {}; } } } |