summaryrefslogtreecommitdiff
path: root/src/mongo/db/concurrency/lock_manager.cpp
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2019-04-02 14:06:20 -0400
committerGregory Wlodarek <gregory.wlodarek@mongodb.com>2019-04-08 14:35:47 -0400
commit28a361799cf6a0d7ea1c3196b19aa9a75795b56d (patch)
tree0e9426b0faa3e6fa80e88d726336632c16e696f5 /src/mongo/db/concurrency/lock_manager.cpp
parent02a87ee5b1942d24e1d7a20502c79d36218929fe (diff)
downloadmongo-28a361799cf6a0d7ea1c3196b19aa9a75795b56d.tar.gz
SERVER-39902 lockInfo should use UUIDCatalog to map resourceIds to collection names
Diffstat (limited to 'src/mongo/db/concurrency/lock_manager.cpp')
-rw-r--r--src/mongo/db/concurrency/lock_manager.cpp56
1 files changed, 8 insertions, 48 deletions
diff --git a/src/mongo/db/concurrency/lock_manager.cpp b/src/mongo/db/concurrency/lock_manager.cpp
index 0862d70e129..237e182d8eb 100644
--- a/src/mongo/db/concurrency/lock_manager.cpp
+++ b/src/mongo/db/concurrency/lock_manager.cpp
@@ -33,13 +33,12 @@
#include "mongo/db/concurrency/lock_manager.h"
-#include <third_party/murmurhash3/MurmurHash3.h>
-
#include "mongo/base/data_type_endian.h"
#include "mongo/base/data_view.h"
#include "mongo/base/static_assert.h"
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/config.h"
+#include "mongo/db/catalog/uuid_catalog.h"
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/concurrency/locker.h"
#include "mongo/util/assert_util.h"
@@ -99,23 +98,6 @@ uint32_t modeMask(LockMode mode) {
return 1 << mode;
}
-uint64_t hashStringData(StringData str) {
- char hash[16];
- MurmurHash3_x64_128(str.rawData(), str.size(), 0, hash);
- return static_cast<size_t>(ConstDataView(hash).read<LittleEndian<std::uint64_t>>());
-}
-
-/**
- * Maps the resource id to a human-readable string.
- */
-static const char* ResourceTypeNames[] = {
- "Invalid", "Global", "Database", "Collection", "Metadata", "Mutex"};
-
-// Ensure we do not add new types without updating the names array
-MONGO_STATIC_ASSERT((sizeof(ResourceTypeNames) / sizeof(ResourceTypeNames[0])) ==
- ResourceTypesCount);
-
-
/**
* Maps the LockRequest status to a human-readable string.
*/
@@ -975,28 +957,6 @@ LockHead* LockManager::LockBucket::findOrInsert(ResourceId resId) {
//
// ResourceId
//
-
-uint64_t ResourceId::fullHash(ResourceType type, uint64_t hashId) {
- return (static_cast<uint64_t>(type) << (64 - resourceTypeBits)) +
- (hashId & (std::numeric_limits<uint64_t>::max() >> resourceTypeBits));
-}
-
-ResourceId::ResourceId(ResourceType type, StringData ns)
- : _fullHash(fullHash(type, hashStringData(ns))) {
-#ifdef MONGO_CONFIG_DEBUG_BUILD
- _nsCopy = ns.toString();
-#endif
-}
-
-ResourceId::ResourceId(ResourceType type, const std::string& ns)
- : _fullHash(fullHash(type, hashStringData(ns))) {
-#ifdef MONGO_CONFIG_DEBUG_BUILD
- _nsCopy = ns;
-#endif
-}
-
-ResourceId::ResourceId(ResourceType type, uint64_t hashId) : _fullHash(fullHash(type, hashId)) {}
-
std::string ResourceId::toString() const {
StringBuilder ss;
ss << "{" << _fullHash << ": " << resourceTypeName(getType()) << ", " << getHashId();
@@ -1004,9 +964,13 @@ std::string ResourceId::toString() const {
ss << ", " << Lock::ResourceMutex::getName(*this);
}
-#ifdef MONGO_CONFIG_DEBUG_BUILD
- ss << ", " << _nsCopy;
-#endif
+ if (getType() == RESOURCE_DATABASE || getType() == RESOURCE_COLLECTION) {
+ UUIDCatalog& uuidCatalog = UUIDCatalog::get(getGlobalServiceContext());
+ boost::optional<std::string> resourceName = uuidCatalog.lookupResourceName(*this);
+ if (resourceName) {
+ ss << ", " << *resourceName;
+ }
+ }
ss << "}";
@@ -1055,10 +1019,6 @@ bool isModeCovered(LockMode mode, LockMode coveringMode) {
LockConflictsTable[coveringMode];
}
-const char* resourceTypeName(ResourceType resourceType) {
- return ResourceTypeNames[resourceType];
-}
-
const char* lockRequestStatusName(LockRequest::Status status) {
return LockRequestStatusNames[status];
}