36 #include "mongo/bson/bsonobj.h" 37 #include "mongo/config.h" 40 #include "mongo/platform/atomic_word.h" 41 #include "mongo/platform/compiler.h" 42 #include "mongo/stdx/condition_variable.h" 43 #include "mongo/stdx/mutex.h" 44 #include "mongo/stdx/unordered_map.h" 45 #include "mongo/util/concurrency/mutex.h" 131 void getLockInfoBSON(
const std::map<LockerId, BSONObj>& lockToClientMap,
132 BSONObjBuilder* result);
145 typedef stdx::unordered_map<ResourceId, LockHead*>
Map;
156 typedef stdx::unordered_map<ResourceId, PartitionedLockHead*>
Map;
183 BSONObjBuilder* result);
191 const std::map<LockerId, BSONObj>& lockToClientMap,
193 BSONArrayBuilder* locks);
260 bool hasCycle()
const;
265 std::string toString()
const;
Definition: lock_manager.h:153
LockBucket * _lockBuckets
Definition: lock_manager.h:215
Definition: lock_manager.h:293
void downgrade(LockRequest *request, LockMode newMode)
Downgrades the mode in which an already granted request is held, without changing the reference count...
Definition: lock_manager.cpp:639
std::map< LockerId, Edges > WaitForGraph
Definition: lock_manager.h:287
Interface for acquiring locks.
Definition: locker.h:47
Entry point for the lock manager scheduling functionality.
Definition: lock_manager.h:53
void _onLockModeChanged(LockHead *lock, bool checkConflictQueue)
Should be invoked when the state of a lock changes in a way, which could potentially allow other bloc...
Definition: lock_manager.cpp:698
DeadlockDetector & check()
Definition: lock_manager.h:240
void _dumpBucket(const LockBucket *bucket) const
Prints the contents of a bucket to the log.
Definition: lock_manager.cpp:893
SimpleMutex mutex
Definition: lock_manager.h:157
Partition * _partitions
Definition: lock_manager.h:218
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
std::deque< UnprocessedNode > UnprocessedNodesQueue
Definition: lock_manager.h:300
Edges(ResourceId resId)
Definition: lock_manager.h:277
uint64_t LockerId
Definition: lock_manager_defs.h:246
LockResult convert(ResourceId resId, LockRequest *request, LockMode newMode)
Definition: lock_manager.cpp:485
LockResult lock(ResourceId resId, LockRequest *request, LockMode mode)
Acquires lock on the specified resource in the specified mode and returns the outcome of the operatio...
Definition: lock_manager.cpp:434
void getLockInfoBSON(const std::map< LockerId, BSONObj > &lockToClientMap, BSONObjBuilder *result)
Dumps the contents of all locks into a BSON object to be used in lockInfo command in the shell...
Definition: lock_manager.cpp:876
There is one of these objects for each resource that has a lock request.
Definition: lock_manager.cpp:140
WaitForGraph::value_type WaitForGraphPair
Definition: lock_manager.h:288
void _dumpBucketToBSON(const std::map< LockerId, BSONObj > &lockToClientMap, const LockBucket *bucket, BSONObjBuilder *result)
Dump the contents of a bucket to the BSON.
Definition: lock_manager.cpp:829
friend class DeadlockDetector
Definition: lock_manager.h:136
Definition: lock_manager.h:143
ResourceId resId
Definition: lock_manager.h:280
stdx::unordered_map< ResourceId, PartitionedLockHead * > Map
Definition: lock_manager.h:156
static const unsigned _numPartitions
Definition: lock_manager.h:217
Uniquely identifies a lockable resource.
Definition: lock_manager_defs.h:176
stdx::unordered_map< ResourceId, LockHead * > Map
Definition: lock_manager.h:145
MONGO_DISALLOW_COPYING(LockManager)
std::vector< LockerId > ConflictingOwnersList
Definition: lock_manager.h:274
UnprocessedNodesQueue _queue
Definition: lock_manager.h:310
Map data
Definition: lock_manager.h:146
UnprocessedNode(LockerId lockerId, ResourceId resId)
Definition: lock_manager.h:294
Definition: lock_manager.h:276
bool unlock(LockRequest *request)
Decrements the reference count of a previously locked request and if the reference count becomes zero...
Definition: lock_manager.cpp:559
const LockerId _initialLockerId
Definition: lock_manager.h:308
Partition * _getPartition(LockRequest *request) const
Retrieves the Partition that a particular LockRequest should use for intent locking.
Definition: lock_manager.cpp:812
LockResult
Return values for the locking functions of the lock manager.
Definition: lock_manager_defs.h:99
LockMode
Lock modes.
Definition: lock_manager_defs.h:59
void _cleanupUnusedLocksInBucket(LockBucket *bucket)
Helper function to delete all locks that have no request on them on a single bucket.
Definition: lock_manager.cpp:669
const LockManager & _lockMgr
Definition: lock_manager.h:307
DiskLoc bucket
Definition: btree_interface.cpp:336
The PartitionedLockHead allows optimizing the case where requests overwhelmingly use the intent lock ...
Definition: lock_manager.cpp:352
Iteratively builds the wait-for graph, starting from a given blocked Locker and stops either when all...
Definition: lock_manager.h:231
ConflictingOwnersList owners
Definition: lock_manager.h:284
SimpleMutex mutex
Definition: lock_manager.h:144
void dump() const
Dumps the contents of all locks to the log.
Definition: lock_manager.cpp:816
LockBucket * _getBucket(ResourceId resId) const
Retrieves the bucket in which the particular resource must reside.
Definition: lock_manager.cpp:808
void _buildBucketBSON(const LockRequest *iter, const std::map< LockerId, BSONObj > &lockToClientMap, const LockBucket *bucket, BSONArrayBuilder *locks)
Build the BSON object containing the lock info for a particular bucket.
Definition: lock_manager.cpp:858
~LockManager()
Definition: lock_manager.cpp:422
There is one of those entries per each request for a lock.
Definition: lock_manager_defs.h:307
bool _foundCycle
Definition: lock_manager.h:313
WaitForGraph _graph
Definition: lock_manager.h:311
LockManager()
Definition: lock_manager.cpp:417
static const unsigned _numLockBuckets
Definition: lock_manager.h:214
ResourceId resId
Definition: lock_manager.h:297
Map data
Definition: lock_manager.h:158
LockHead * findOrInsert(ResourceId resId)
Definition: lock_manager.cpp:958
LockerId lockerId
Definition: lock_manager.h:296
void cleanupUnusedLocks()
Iterates through all buckets and deletes all locks, which have no requests on them.
Definition: lock_manager.cpp:661