summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/tenant_oplog_applier.cpp
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2022-08-24 07:04:40 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-08-24 12:23:08 +0000
commitdbb9f3a2783be8581a91373dfb5de8eef66df656 (patch)
tree14600eb0ea481c454aa72a08fc01ed4e31b1b5c8 /src/mongo/db/repl/tenant_oplog_applier.cpp
parent3b63216fb7beabecb79d51b291f7f49ac1a8ba1c (diff)
downloadmongo-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.cpp18
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 = {};
}
}
}