diff options
author | Nathan Louie <nathan.louie@10gen.com> | 2018-08-16 16:18:00 -0400 |
---|---|---|
committer | jinichu <jinnybyun@gmail.com> | 2018-08-16 16:18:00 -0400 |
commit | 199963de3d57ffcb1db7acd75911d547a4cd6f31 (patch) | |
tree | 27417954c76ece7f2d9035adebb12e51a87d7a41 | |
parent | 562d076100007c2b130ce4b6f9ec9740463bba7b (diff) | |
download | mongo-199963de3d57ffcb1db7acd75911d547a4cd6f31.tar.gz |
SERVER-36461 Add 'transaction' identifier to slow transaction log output
(cherry picked from commit 4b6a5591cf912f6cadaf2f1ede5d58ad2bb694c6)
-rw-r--r-- | src/mongo/db/session.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/session_test.cpp | 6 | ||||
-rw-r--r-- | src/mongo/logger/log_component.cpp | 4 | ||||
-rw-r--r-- | src/mongo/logger/log_component.h | 1 |
4 files changed, 10 insertions, 4 deletions
diff --git a/src/mongo/db/session.cpp b/src/mongo/db/session.cpp index 8c2b7c51805..db7981d4671 100644 --- a/src/mongo/db/session.cpp +++ b/src/mongo/db/session.cpp @@ -1234,7 +1234,8 @@ void Session::_logSlowTransaction(WithLock wl, // Log the transaction if its duration is longer than the slowMS command threshold. if (_singleTransactionStats->getDuration(curTimeMicros64()) > serverGlobalParams.slowMS * 1000ULL) { - log(logger::LogComponent::kCommand) + log(logger::LogComponent::kTransaction) + << "transaction " << _transactionInfoForLog(lockStats, terminationCause, readConcernArgs); } } diff --git a/src/mongo/db/session_test.cpp b/src/mongo/db/session_test.cpp index 85fe5393633..aad445260ec 100644 --- a/src/mongo/db/session_test.cpp +++ b/src/mongo/db/session_test.cpp @@ -2497,7 +2497,7 @@ TEST_F(TransactionsMetricsTest, LogTransactionInfoAfterSlowCommit) { const auto lockerInfo = opCtx()->lockState()->getLockerInfo(); ASSERT(lockerInfo); - std::string expectedTransactionInfo = + std::string expectedTransactionInfo = "transaction " + session.transactionInfoForLogForTest(&lockerInfo->stats, true, readConcernArgs); ASSERT_EQUALS(1, countLogLinesContaining(expectedTransactionInfo)); } @@ -2535,7 +2535,7 @@ TEST_F(TransactionsMetricsTest, LogTransactionInfoAfterSlowAbort) { const auto lockerInfo = opCtx()->lockState()->getLockerInfo(); ASSERT(lockerInfo); - std::string expectedTransactionInfo = + std::string expectedTransactionInfo = "transaction " + session.transactionInfoForLogForTest(&lockerInfo->stats, false, readConcernArgs); ASSERT_EQUALS(1, countLogLinesContaining(expectedTransactionInfo)); } @@ -2576,7 +2576,7 @@ TEST_F(TransactionsMetricsTest, LogTransactionInfoAfterSlowStashedAbort) { session.abortArbitraryTransaction(); stopCapturingLogMessages(); - std::string expectedTransactionInfo = + std::string expectedTransactionInfo = "transaction " + session.transactionInfoForLogForTest(&lockerInfo->stats, false, readConcernArgs); ASSERT_EQUALS(1, countLogLinesContaining(expectedTransactionInfo)); } diff --git a/src/mongo/logger/log_component.cpp b/src/mongo/logger/log_component.cpp index 757084d84f4..31ca2c68f03 100644 --- a/src/mongo/logger/log_component.cpp +++ b/src/mongo/logger/log_component.cpp @@ -130,6 +130,8 @@ StringData LogComponent::toStringData() const { return "bridge"_sd; case kTracking: return "tracking"_sd; + case kTransaction: + return "transaction"_sd; case kNumLogComponents: return "total"_sd; // No default. Compiler should complain if there's a log component that's not handled. @@ -208,6 +210,8 @@ StringData LogComponent::getNameForLog() const { return "BRIDGE "_sd; case kTracking: return "TRACKING"_sd; + case kTransaction: + return "TXN "_sd; case kNumLogComponents: return "TOTAL "_sd; // No default. Compiler should complain if there's a log component that's not handled. diff --git a/src/mongo/logger/log_component.h b/src/mongo/logger/log_component.h index 76eb1b005d6..af6f0a03f25 100644 --- a/src/mongo/logger/log_component.h +++ b/src/mongo/logger/log_component.h @@ -64,6 +64,7 @@ public: kASIO, kBridge, kTracking, + kTransaction, kNumLogComponents }; |