diff options
author | Gabriel Russell <gabriel.russell@mongodb.com> | 2020-02-13 11:49:46 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-02-13 18:16:35 +0000 |
commit | a84c09a19720b73cedb2e8ef7c5cfeedfa1c9761 (patch) | |
tree | 85ac46cd5f4ea6d5134560bf764fb9e6cf11fe4e /src/mongo/db/concurrency | |
parent | 6df40e01f7b6899affc4536e7e73a35802cabf98 (diff) | |
download | mongo-a84c09a19720b73cedb2e8ef7c5cfeedfa1c9761.tar.gz |
SERVER-45869 automatically converted structured logging
Diffstat (limited to 'src/mongo/db/concurrency')
-rw-r--r-- | src/mongo/db/concurrency/d_concurrency_test.cpp | 11 | ||||
-rw-r--r-- | src/mongo/db/concurrency/deferred_writer.cpp | 13 | ||||
-rw-r--r-- | src/mongo/db/concurrency/flow_control_ticketholder.cpp | 11 | ||||
-rw-r--r-- | src/mongo/db/concurrency/lock_manager.cpp | 7 | ||||
-rw-r--r-- | src/mongo/db/concurrency/lock_state.cpp | 5 |
5 files changed, 34 insertions, 13 deletions
diff --git a/src/mongo/db/concurrency/d_concurrency_test.cpp b/src/mongo/db/concurrency/d_concurrency_test.cpp index bf2b8bd62ff..8d00a0f1f44 100644 --- a/src/mongo/db/concurrency/d_concurrency_test.cpp +++ b/src/mongo/db/concurrency/d_concurrency_test.cpp @@ -43,6 +43,7 @@ #include "mongo/db/concurrency/write_conflict_exception.h" #include "mongo/db/service_context_d_test_fixture.h" #include "mongo/db/storage/recovery_unit_noop.h" +#include "mongo/logv2/log.h" #include "mongo/stdx/future.h" #include "mongo/stdx/thread.h" #include "mongo/unittest/unittest.h" @@ -2074,9 +2075,13 @@ TEST_F(DConcurrencyTestFixture, CompatibleFirstStress) { for (auto& thread : threads) thread.join(); for (int threadId = 0; threadId < numThreads; threadId++) { - log() << "thread " << threadId << " stats: " << acquisitionCount[threadId] - << " acquisitions, " << timeoutCount[threadId] << " timeouts, " - << busyWaitCount[threadId] / 1'000'000 << "M busy waits"; + LOGV2(20515, + "thread {threadId} stats: {acquisitionCount_threadId} acquisitions, " + "{timeoutCount_threadId} timeouts, {busyWaitCount_threadId_1_000_000}M busy waits", + "threadId"_attr = threadId, + "acquisitionCount_threadId"_attr = acquisitionCount[threadId], + "timeoutCount_threadId"_attr = timeoutCount[threadId], + "busyWaitCount_threadId_1_000_000"_attr = busyWaitCount[threadId] / 1'000'000); } } diff --git a/src/mongo/db/concurrency/deferred_writer.cpp b/src/mongo/db/concurrency/deferred_writer.cpp index 4bedbe1995c..b06d4faa127 100644 --- a/src/mongo/db/concurrency/deferred_writer.cpp +++ b/src/mongo/db/concurrency/deferred_writer.cpp @@ -35,6 +35,7 @@ #include "mongo/db/concurrency/write_conflict_exception.h" #include "mongo/db/db_raii.h" #include "mongo/db/operation_context.h" +#include "mongo/logv2/log.h" #include "mongo/util/concurrency/idle_thread_block.h" #include "mongo/util/concurrency/thread_pool.h" #include "mongo/util/log.h" @@ -47,7 +48,10 @@ auto kLogInterval = stdx::chrono::minutes(1); void DeferredWriter::_logFailure(const Status& status) { if (TimePoint::clock::now() - _lastLogged > kLogInterval) { - log() << "Unable to write to collection " << _nss.toString() << ": " << status.toString(); + LOGV2(20516, + "Unable to write to collection {nss}: {status}", + "nss"_attr = _nss.toString(), + "status"_attr = status.toString()); _lastLogged = stdx::chrono::system_clock::now(); } } @@ -55,8 +59,11 @@ void DeferredWriter::_logFailure(const Status& status) { void DeferredWriter::_logDroppedEntry() { _droppedEntries += 1; if (TimePoint::clock::now() - _lastLoggedDrop > kLogInterval) { - log() << "Deferred write buffer for " << _nss.toString() << " is full. " << _droppedEntries - << " entries have been dropped."; + LOGV2( + 20517, + "Deferred write buffer for {nss} is full. {droppedEntries} entries have been dropped.", + "nss"_attr = _nss.toString(), + "droppedEntries"_attr = _droppedEntries); _lastLoggedDrop = stdx::chrono::system_clock::now(); _droppedEntries = 0; } diff --git a/src/mongo/db/concurrency/flow_control_ticketholder.cpp b/src/mongo/db/concurrency/flow_control_ticketholder.cpp index 4a8057159e1..a11c4b399c4 100644 --- a/src/mongo/db/concurrency/flow_control_ticketholder.cpp +++ b/src/mongo/db/concurrency/flow_control_ticketholder.cpp @@ -34,6 +34,7 @@ #include "mongo/db/concurrency/flow_control_ticketholder.h" #include "mongo/db/operation_context.h" +#include "mongo/logv2/log.h" #include "mongo/util/log.h" #include "mongo/util/time_support.h" @@ -81,7 +82,11 @@ void FlowControlTicketholder::set(ServiceContext* service, void FlowControlTicketholder::refreshTo(int numTickets) { invariant(numTickets >= 0); stdx::lock_guard<Latch> lk(_mutex); - LOG(4) << "Refreshing tickets. Before: " << _tickets << " Now: " << numTickets; + LOGV2_DEBUG(20518, + 4, + "Refreshing tickets. Before: {tickets} Now: {numTickets}", + "tickets"_attr = _tickets, + "numTickets"_attr = numTickets); _tickets = numTickets; _cv.notify_all(); } @@ -93,7 +98,7 @@ void FlowControlTicketholder::getTicket(OperationContext* opCtx, return; } - LOG(4) << "Taking ticket. Available: " << _tickets; + LOGV2_DEBUG(20519, 4, "Taking ticket. Available: {tickets}", "tickets"_attr = _tickets); if (_tickets == 0) { ++stats->acquireWaitCount; } @@ -130,7 +135,7 @@ void FlowControlTicketholder::getTicket(OperationContext* opCtx, // Should only be called once, during shutdown. void FlowControlTicketholder::setInShutdown() { - LOG(0) << "Stopping further Flow Control ticket acquisitions."; + LOGV2(20520, "Stopping further Flow Control ticket acquisitions."); stdx::lock_guard<Latch> lk(_mutex); _inShutdown = true; _cv.notify_all(); diff --git a/src/mongo/db/concurrency/lock_manager.cpp b/src/mongo/db/concurrency/lock_manager.cpp index 0ab21e4c425..b27c632c7ee 100644 --- a/src/mongo/db/concurrency/lock_manager.cpp +++ b/src/mongo/db/concurrency/lock_manager.cpp @@ -41,6 +41,7 @@ #include "mongo/db/catalog/collection_catalog.h" #include "mongo/db/concurrency/d_concurrency.h" #include "mongo/db/concurrency/locker.h" +#include "mongo/logv2/log.h" #include "mongo/util/assert_util.h" #include "mongo/util/log.h" #include "mongo/util/str.h" @@ -826,7 +827,9 @@ LockManager::Partition* LockManager::_getPartition(LockRequest* request) const { } void LockManager::dump() const { - log() << "Dumping LockManager @ " << reinterpret_cast<uint64_t>(this) << '\n'; + LOGV2(20521, + "Dumping LockManager @ {reinterpret_cast_uint64_t_this}", + "reinterpret_cast_uint64_t_this"_attr = reinterpret_cast<uint64_t>(this)); auto lockToClientMap = getLockToClientMap(getGlobalServiceContext()); for (unsigned i = 0; i < _numLockBuckets; i++) { @@ -963,7 +966,7 @@ void LockManager::_dumpBucket(const std::map<LockerId, BSONObj>& lockToClientMap } sb << "-----------------------------------------------------------\n"; - log() << sb.str(); + LOGV2(20522, "{sb_str}", "sb_str"_attr = sb.str()); } } diff --git a/src/mongo/db/concurrency/lock_state.cpp b/src/mongo/db/concurrency/lock_state.cpp index 3f98a7322b3..2b2f104dacc 100644 --- a/src/mongo/db/concurrency/lock_state.cpp +++ b/src/mongo/db/concurrency/lock_state.cpp @@ -39,6 +39,7 @@ #include "mongo/db/namespace_string.h" #include "mongo/db/service_context.h" #include "mongo/db/storage/flow_control.h" +#include "mongo/logv2/log.h" #include "mongo/platform/compiler.h" #include "mongo/stdx/new.h" #include "mongo/util/background.h" @@ -203,7 +204,7 @@ void LockerImpl::dump() const { } _lock.unlock(); - log() << ss.str(); + LOGV2(20523, "{ss_str}", "ss_str"_attr = ss.str()); } @@ -1062,7 +1063,7 @@ public: } void taskDoWork() { - LOG(2) << "cleaning up unused lock buckets of the global lock manager"; + LOGV2_DEBUG(20524, 2, "cleaning up unused lock buckets of the global lock manager"); getGlobalLockManager()->cleanupUnusedLocks(); } } unusedLockCleaner; |