diff options
author | Jason Chan <jason.chan@mongodb.com> | 2021-01-06 21:13:38 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-02-05 01:23:31 +0000 |
commit | 7883bfe8349b4439f55fd8d4199fab1455b6d67d (patch) | |
tree | 0500250cd5a519870e86605a3b01b2b5826a4aaf /src | |
parent | 95d8e9e4ecbc53daad0dd637da8ac85931ff2b04 (diff) | |
download | mongo-7883bfe8349b4439f55fd8d4199fab1455b6d67d.tar.gz |
SERVER-53609 Filter out serverStatus.transactions.lastCommittedTransaction from FTDC
(cherry picked from commit 3e5fc29b410b4a0e999f190de5f035e3119f6565)
(cherry picked from commit 97f5866b751246f4b035ebe1cff7ac371e2430fa)
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/ftdc/ftdc_server.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/server_transactions_metrics.cpp | 11 | ||||
-rw-r--r-- | src/mongo/db/server_transactions_metrics.h | 3 |
3 files changed, 13 insertions, 6 deletions
diff --git a/src/mongo/db/ftdc/ftdc_server.cpp b/src/mongo/db/ftdc/ftdc_server.cpp index a46a0106262..0bb8f311a84 100644 --- a/src/mongo/db/ftdc/ftdc_server.cpp +++ b/src/mongo/db/ftdc/ftdc_server.cpp @@ -299,8 +299,9 @@ void startFTDC(boost::filesystem::path& path, "serverStatus", "serverStatus", "", - BSON("serverStatus" << 1 << "tcMalloc" << true << "sharding" << false << "timing" - << false))); + BSON("serverStatus" << 1 << "tcMalloc" << true << "sharding" << false << "timing" << false + << "transactions" + << BSON("includeLastCommitted" << false)))); registerCollectors(controller.get()); diff --git a/src/mongo/db/server_transactions_metrics.cpp b/src/mongo/db/server_transactions_metrics.cpp index da5f2b8a112..e96222170d7 100644 --- a/src/mongo/db/server_transactions_metrics.cpp +++ b/src/mongo/db/server_transactions_metrics.cpp @@ -125,7 +125,7 @@ void ServerTransactionsMetrics::updateLastTransaction(size_t operationCount, _lastCommittedTransaction->setWriteConcern(std::move(writeConcern)); } -void ServerTransactionsMetrics::updateStats(TransactionsStats* stats) { +void ServerTransactionsMetrics::updateStats(TransactionsStats* stats, bool includeLastCommitted) { stats->setCurrentActive(_currentActive.load()); stats->setCurrentInactive(_currentInactive.load()); stats->setCurrentOpen(_currentOpen.load()); @@ -134,7 +134,7 @@ void ServerTransactionsMetrics::updateStats(TransactionsStats* stats) { stats->setTotalStarted(_totalStarted.load()); stdx::lock_guard<stdx::mutex> lg(_mutex); - if (_lastCommittedTransaction) { + if (_lastCommittedTransaction && includeLastCommitted) { stats->setLastCommittedTransaction(*_lastCommittedTransaction); } } @@ -153,12 +153,17 @@ public: const BSONElement& configElement) const { TransactionsStats stats; + bool includeLastCommitted = true; + if (configElement.type() == BSONType::Object) { + includeLastCommitted = configElement.Obj()["includeLastCommitted"].trueValue(); + } + // Retryable writes and multi-document transactions metrics are both included in the same // serverStatus section because both utilize similar internal machinery for tracking their // lifecycle within a session. Both are assigned transaction numbers, and so both are often // referred to as “transactions”. RetryableWritesStats::get(opCtx)->updateStats(&stats); - ServerTransactionsMetrics::get(opCtx)->updateStats(&stats); + ServerTransactionsMetrics::get(opCtx)->updateStats(&stats, includeLastCommitted); return stats.toBSON(); } diff --git a/src/mongo/db/server_transactions_metrics.h b/src/mongo/db/server_transactions_metrics.h index 02f397cde9e..c2d1270877f 100644 --- a/src/mongo/db/server_transactions_metrics.h +++ b/src/mongo/db/server_transactions_metrics.h @@ -75,8 +75,9 @@ public: /** * Appends the accumulated stats to a transactions stats object. + * Include the 'lastCommittedTransactions' field if 'includeLastCommitted' is true. */ - void updateStats(TransactionsStats* stats); + void updateStats(TransactionsStats* stats, bool includeLastCommitted); private: // The number of multi-document transactions currently active. |