diff options
author | Benety Goh <benety@mongodb.com> | 2019-10-11 21:26:36 +0000 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2020-01-15 14:04:51 -0500 |
commit | ce0a2242ca1d939cc2102857d5def9e068ebebe8 (patch) | |
tree | 3b85b617da87edd135bd7e9b0a533e28b52ddb1a | |
parent | 41981ad8d67b3fc95da21506751cc5d284e724e1 (diff) | |
download | mongo-ce0a2242ca1d939cc2102857d5def9e068ebebe8.tar.gz |
SERVER-43910 LockManager::dump() includes client info
(cherry picked from commit 1245770e0ac12d09bceec097fcf66865b040a463)
-rw-r--r-- | src/mongo/db/concurrency/lock_manager.cpp | 28 | ||||
-rw-r--r-- | src/mongo/db/concurrency/lock_manager.h | 3 |
2 files changed, 24 insertions, 7 deletions
diff --git a/src/mongo/db/concurrency/lock_manager.cpp b/src/mongo/db/concurrency/lock_manager.cpp index 16341611a7c..49711a7637a 100644 --- a/src/mongo/db/concurrency/lock_manager.cpp +++ b/src/mongo/db/concurrency/lock_manager.cpp @@ -844,12 +844,13 @@ LockManager::Partition* LockManager::_getPartition(LockRequest* request) const { void LockManager::dump() const { log() << "Dumping LockManager @ " << static_cast<const void*>(this) << '\n'; + auto lockToClientMap = getLockToClientMap(getGlobalServiceContext()); for (unsigned i = 0; i < _numLockBuckets; i++) { LockBucket* bucket = &_lockBuckets[i]; stdx::lock_guard<SimpleMutex> scopedLock(bucket->mutex); if (!bucket->data.empty()) { - _dumpBucket(bucket); + _dumpBucket(lockToClientMap, bucket); } } } @@ -919,7 +920,8 @@ void LockManager::getLockInfoBSON(const std::map<LockerId, BSONObj>& lockToClien result->append("lockInfo", lockInfo.arr()); } -void LockManager::_dumpBucket(const LockBucket* bucket) const { +void LockManager::_dumpBucket(const std::map<LockerId, BSONObj>& lockToClientMap, + const LockBucket* bucket) const { for (LockBucket::Map::const_iterator it = bucket->data.begin(); it != bucket->data.end(); it++) { const LockHead* lock = it->second; @@ -938,13 +940,20 @@ void LockManager::_dumpBucket(const LockBucket* bucket) const { std::stringstream threadId; threadId << iter->locker->getThreadId() << " | " << std::showbase << std::hex << iter->locker->getThreadId(); - sb << '\t' << "LockRequest " << iter->locker->getId() << " @ " << iter->locker << ": " + auto lockerId = iter->locker->getId(); + sb << '\t' << "LockRequest " << lockerId << " @ " << iter->locker << ": " << "Mode = " << modeName(iter->mode) << "; " << "Thread = " << threadId.str() << "; " << "ConvertMode = " << modeName(iter->convertMode) << "; " << "EnqueueAtFront = " << iter->enqueueAtFront << "; " << "CompatibleFirst = " << iter->compatibleFirst << "; " - << "DebugInfo = " << iter->locker->getDebugInfo() << '\n'; + << "DebugInfo = " << iter->locker->getDebugInfo(); + auto it = lockToClientMap.find(lockerId); + if (it != lockToClientMap.end()) { + sb << "; ClientInfo = "; + sb << it->second; + } + sb << '\n'; } sb << "PENDING:\n"; @@ -953,13 +962,20 @@ void LockManager::_dumpBucket(const LockBucket* bucket) const { std::stringstream threadId; threadId << iter->locker->getThreadId() << " | " << std::showbase << std::hex << iter->locker->getThreadId(); - sb << '\t' << "LockRequest " << iter->locker->getId() << " @ " << iter->locker << ": " + auto lockerId = iter->locker->getId(); + sb << '\t' << "LockRequest " << lockerId << " @ " << iter->locker << ": " << "Mode = " << modeName(iter->mode) << "; " << "Thread = " << threadId.str() << "; " << "ConvertMode = " << modeName(iter->convertMode) << "; " << "EnqueueAtFront = " << iter->enqueueAtFront << "; " << "CompatibleFirst = " << iter->compatibleFirst << "; " - << "DebugInfo = " << iter->locker->getDebugInfo() << '\n'; + << "DebugInfo = " << iter->locker->getDebugInfo(); + auto it = lockToClientMap.find(lockerId); + if (it != lockToClientMap.end()) { + sb << "; ClientInfo = "; + sb << it->second; + } + sb << '\n'; } sb << "-----------------------------------------------------------\n"; diff --git a/src/mongo/db/concurrency/lock_manager.h b/src/mongo/db/concurrency/lock_manager.h index 5777998c00c..23603eaea3c 100644 --- a/src/mongo/db/concurrency/lock_manager.h +++ b/src/mongo/db/concurrency/lock_manager.h @@ -183,7 +183,8 @@ private: /** * Prints the contents of a bucket to the log. */ - void _dumpBucket(const LockBucket* bucket) const; + void _dumpBucket(const std::map<LockerId, BSONObj>& lockToClientMap, + const LockBucket* bucket) const; /** * Dump the contents of a bucket to the BSON. |