summaryrefslogtreecommitdiff
path: root/src/mongo/db/session.cpp
diff options
context:
space:
mode:
authorWilliam Schultz <william.schultz@mongodb.com>2018-08-16 16:18:00 -0400
committerjinichu <jinnybyun@gmail.com>2018-08-16 16:18:00 -0400
commit15b6b95877b09d9a2c5d2f63a981692545875c3a (patch)
tree1e429de46485fc93e7e6e0e3b2c7336e724e7695 /src/mongo/db/session.cpp
parent48c0ef6564b153b70ff307818c016c2cc36b3ab8 (diff)
downloadmongo-15b6b95877b09d9a2c5d2f63a981692545875c3a.tar.gz
SERVER-36294 Mark transaction as inactive when it is first marked as open
(cherry picked from commit 95bcc2148cc7ec3ca4f54e16c4a75bbc0f806ace)
Diffstat (limited to 'src/mongo/db/session.cpp')
-rw-r--r--src/mongo/db/session.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/mongo/db/session.cpp b/src/mongo/db/session.cpp
index 7d1176672c5..27b42bb2ad8 100644
--- a/src/mongo/db/session.cpp
+++ b/src/mongo/db/session.cpp
@@ -611,7 +611,9 @@ void Session::_beginOrContinueTxn(WithLock wl,
Date_t::fromMillisSinceEpoch(_singleTransactionStats->getStartTime() / 1000) +
stdx::chrono::seconds{transactionLifetimeLimitSeconds.load()};
ServerTransactionsMetrics::get(getGlobalServiceContext())->incrementTotalStarted();
+ // The transaction is considered open here and stays inactive until its first unstash event.
ServerTransactionsMetrics::get(getGlobalServiceContext())->incrementCurrentOpen();
+ ServerTransactionsMetrics::get(getGlobalServiceContext())->incrementCurrentInactive();
} else {
// Execute a retryable write.
invariant(startTransaction == boost::none);
@@ -803,6 +805,7 @@ void Session::unstashTransactionResources(OperationContext* opCtx, const std::st
}
opCtx->setWriteUnitOfWork(std::make_unique<WriteUnitOfWork>(opCtx));
ServerTransactionsMetrics::get(getGlobalServiceContext())->incrementCurrentActive();
+ ServerTransactionsMetrics::get(getGlobalServiceContext())->decrementCurrentInactive();
// Set the starting active time for this transaction.
_singleTransactionStats->setActive(curTimeMicros64());