summaryrefslogtreecommitdiff
path: root/src/mongo/db/transaction_metrics_observer.cpp
diff options
context:
space:
mode:
authorMatthew Russotto <matthew.russotto@10gen.com>2019-08-21 09:54:58 -0400
committerMatthew Russotto <matthew.russotto@10gen.com>2019-08-21 09:54:58 -0400
commitf661267bf981e3b315d7e942057ab0ac9dc90bef (patch)
tree24968a20050d47b9644dc64dfa0c7b542b01d90e /src/mongo/db/transaction_metrics_observer.cpp
parentf5ee95fe7e9e6ca3db9db01e97a917f754d4d8cd (diff)
downloadmongo-f661267bf981e3b315d7e942057ab0ac9dc90bef.tar.gz
SERVER-41457 Unify the different ways the TransactionParticipant offers for aborting a transaction
Diffstat (limited to 'src/mongo/db/transaction_metrics_observer.cpp')
-rw-r--r--src/mongo/db/transaction_metrics_observer.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/mongo/db/transaction_metrics_observer.cpp b/src/mongo/db/transaction_metrics_observer.cpp
index ad0ce535173..e1b36d971bd 100644
--- a/src/mongo/db/transaction_metrics_observer.cpp
+++ b/src/mongo/db/transaction_metrics_observer.cpp
@@ -138,18 +138,12 @@ void TransactionMetricsObserver::_onAbortActive(
// Server wide transactions metrics.
//
serverTransactionsMetrics->decrementCurrentActive();
-
- if (_singleTransactionStats.isPrepared()) {
- serverTransactionsMetrics->incrementTotalPreparedThenAborted();
- serverTransactionsMetrics->decrementCurrentPrepared();
- }
}
void TransactionMetricsObserver::_onAbortInactive(
ServerTransactionsMetrics* serverTransactionsMetrics, TickSource* tickSource, Top* top) {
auto curTick = tickSource->getTicks();
invariant(!_singleTransactionStats.isActive());
- invariant(!_singleTransactionStats.isPrepared());
_onAbort(serverTransactionsMetrics, curTick, tickSource, top);
//
@@ -213,6 +207,11 @@ void TransactionMetricsObserver::_onAbort(ServerTransactionsMetrics* serverTrans
serverTransactionsMetrics->incrementTotalAborted();
serverTransactionsMetrics->decrementCurrentOpen();
+ if (_singleTransactionStats.isPrepared()) {
+ serverTransactionsMetrics->incrementTotalPreparedThenAborted();
+ serverTransactionsMetrics->decrementCurrentPrepared();
+ }
+
auto latency =
durationCount<Microseconds>(_singleTransactionStats.getDuration(tickSource, curTick));
top->incrementGlobalTransactionLatencyStats(static_cast<uint64_t>(latency));