From ace1aec25c5324fb51083e266757e48ef664be55 Mon Sep 17 00:00:00 2001 From: Nathan Louie Date: Tue, 19 Jun 2018 11:29:24 -0400 Subject: initial review --- src/mongo/db/server_transactions_metrics.h | 10 ++++------ src/mongo/db/session.cpp | 7 +++++++ 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mongo/db/server_transactions_metrics.h b/src/mongo/db/server_transactions_metrics.h index 6ed3aad007c..f877a1f8b23 100644 --- a/src/mongo/db/server_transactions_metrics.h +++ b/src/mongo/db/server_transactions_metrics.h @@ -46,11 +46,6 @@ public: static ServerTransactionsMetrics* get(ServiceContext* service); static ServerTransactionsMetrics* get(OperationContext* opCtx); -<<<<<<< HEAD - unsigned long long getCurrentOpen() const; - void decrementCurrentOpen(); - void incrementCurrentOpen(); -======= unsigned long long getCurrentActive() const; void decrementCurrentActive(); void incrementCurrentActive(); @@ -58,7 +53,10 @@ public: unsigned long long getCurrentInactive() const; void decrementCurrentInactive(); void incrementCurrentInactive(); ->>>>>>> 40c317ccbb... added to class + + unsigned long long getCurrentOpen() const; + void decrementCurrentOpen(); + void incrementCurrentOpen(); unsigned long long getTotalStarted() const; void incrementTotalStarted(); diff --git a/src/mongo/db/session.cpp b/src/mongo/db/session.cpp index cb511947cff..04b56675a5b 100644 --- a/src/mongo/db/session.cpp +++ b/src/mongo/db/session.cpp @@ -597,6 +597,7 @@ void Session::_beginOrContinueTxn(WithLock wl, stdx::chrono::seconds{transactionLifetimeLimitSeconds.load()}; ServerTransactionsMetrics::get(getGlobalServiceContext())->incrementTotalStarted(); ServerTransactionsMetrics::get(getGlobalServiceContext())->incrementCurrentOpen(); + ServerTransactionsMetrics::get(getGlobalServiceContext())->incrementCurrentActive(); } else { // Execute a retryable write. invariant(startTransaction == boost::none); @@ -725,6 +726,8 @@ void Session::stashTransactionResources(OperationContext* opCtx) { invariant(!_txnResourceStash); _txnResourceStash = TxnResources(opCtx); + ServerTransactionsMetrics::get(opCtx)->decrementCurrentActive(); + ServerTransactionsMetrics::get(opCtx)->incrementCurrentInactive(); } void Session::unstashTransactionResources(OperationContext* opCtx, const std::string& cmdName) { @@ -778,6 +781,8 @@ void Session::unstashTransactionResources(OperationContext* opCtx, const std::st if (_txnState == MultiDocumentTransactionState::kInProgress) { _singleTransactionStats->setActive(curTimeMicros64()); } + ServerTransactionsMetrics::get(opCtx)->incrementCurrentActive(); + ServerTransactionsMetrics::get(opCtx)->decrementCurrentInactive(); return; } @@ -917,6 +922,7 @@ void Session::_abortTransaction(WithLock wl) { } } ServerTransactionsMetrics::get(getGlobalServiceContext())->decrementCurrentOpen(); + ServerTransactionsMetrics::get(getGlobalServiceContext())->decrementCurrentInactive(); } void Session::_beginOrContinueTxnOnMigration(WithLock wl, TxnNumber txnNumber) { @@ -1054,6 +1060,7 @@ void Session::_commitTransaction(stdx::unique_lock lk, OperationCon _singleTransactionStats->setInactive(curTimeMicros64()); } ServerTransactionsMetrics::get(opCtx)->decrementCurrentOpen(); + ServerTransactionsMetrics::get(getGlobalServiceContext())->decrementCurrentActive(); } BSONObj Session::reportStashedState() const { -- cgit v1.2.1