diff options
author | Sanika Phanse <sanika.phanse@mongodb.com> | 2022-01-24 19:21:10 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-01-24 20:47:47 +0000 |
commit | 6b587168a727843ae46ee5da9be59bfe224b6649 (patch) | |
tree | 8e2799a45c57470773a5b02f9d500a2e15d7721e /src/mongo/db/stats | |
parent | 757f44e1a1cc496f8030e00249aaf43163a85677 (diff) | |
download | mongo-6b587168a727843ae46ee5da9be59bfe224b6649.tar.gz |
SERVER-61121 Make TransactionMetricsObserver support TxnNumberAndRetryCounter
Diffstat (limited to 'src/mongo/db/stats')
-rw-r--r-- | src/mongo/db/stats/single_transaction_stats.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/stats/single_transaction_stats.h | 10 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/mongo/db/stats/single_transaction_stats.cpp b/src/mongo/db/stats/single_transaction_stats.cpp index 386a2568d45..3234998fb28 100644 --- a/src/mongo/db/stats/single_transaction_stats.cpp +++ b/src/mongo/db/stats/single_transaction_stats.cpp @@ -116,7 +116,7 @@ void SingleTransactionStats::report(BSONObjBuilder* builder, TickSource* tickSource, TickSource::Tick curTick) const { BSONObjBuilder parametersBuilder(builder->subobjStart("parameters")); - parametersBuilder.append("txnNumber", _txnNumber); + parametersBuilder.append("txnNumber", _txnNumberAndRetryCounter.getTxnNumber()); if (!isForMultiDocumentTransaction()) { // For retryable writes, we only include the txnNumber. @@ -124,6 +124,7 @@ void SingleTransactionStats::report(BSONObjBuilder* builder, return; } + parametersBuilder.append("txnRetryCounter", *_txnNumberAndRetryCounter.getTxnRetryCounter()); parametersBuilder.append("autocommit", *_autoCommit); readConcernArgs.appendInfo(¶metersBuilder); parametersBuilder.done(); diff --git a/src/mongo/db/stats/single_transaction_stats.h b/src/mongo/db/stats/single_transaction_stats.h index 51524c8d01c..fa987e08a02 100644 --- a/src/mongo/db/stats/single_transaction_stats.h +++ b/src/mongo/db/stats/single_transaction_stats.h @@ -62,8 +62,10 @@ public: } }; - SingleTransactionStats() : _txnNumber(kUninitializedTxnNumber){}; - SingleTransactionStats(TxnNumber txnNumber) : _txnNumber(txnNumber){}; + SingleTransactionStats() + : _txnNumberAndRetryCounter(kUninitializedTxnNumber, kUninitializedTxnRetryCounter){}; + SingleTransactionStats(TxnNumberAndRetryCounter txnNumberAndRetryCounter) + : _txnNumberAndRetryCounter(txnNumberAndRetryCounter){}; /** * Sets the transaction's start time, only if it hasn't already been set. @@ -226,8 +228,8 @@ public: TickSource::Tick curTick) const; private: - // The transaction number of the transaction. - TxnNumber _txnNumber; + // The struct containing the transaction number and transaction retry counter. + TxnNumberAndRetryCounter _txnNumberAndRetryCounter; // Unset for retryable write, 'false' for multi-document transaction. Value 'true' is // for future use. |