예제 #1
0
OperationContextSession::OperationContextSession(OperationContext* opCtx) : _opCtx(opCtx) {
    if (!opCtx->getLogicalSessionId()) {
        return;
    }

    auto sessionTransactionTable = SessionCatalog::get(opCtx);

    auto& operationSession = operationSessionDecoration(opCtx);
    operationSession.emplace(sessionTransactionTable->checkOutSession(opCtx));
}
예제 #2
0
OperationContextSession::OperationContextSession(OperationContext* opCtx) : _opCtx(opCtx) {
    if (!opCtx->getLogicalSessionId()) {
        return;
    }

    auto& checkedOutSession = operationSessionDecoration(opCtx);
    if (!checkedOutSession) {
        auto sessionTransactionTable = SessionCatalog::get(opCtx);
        checkedOutSession.emplace(sessionTransactionTable->checkOutSession(opCtx));
    }

    const auto session = checkedOutSession->scopedSession.get();
    invariant(opCtx->getLogicalSessionId() == session->getSessionId());

    checkedOutSession->checkOutNestingLevel++;

    if (checkedOutSession->checkOutNestingLevel > 1) {
        return;
    }

    if (opCtx->getTxnNumber()) {
        checkedOutSession->scopedSession->begin(opCtx, opCtx->getTxnNumber().get());
    }
}