summaryrefslogtreecommitdiff
path: root/src/mongo/db/concurrency/lock_manager.h
diff options
context:
space:
mode:
authorGeert Bosch <geert@mongodb.com>2018-11-14 11:29:24 -0500
committerGeert Bosch <geert@mongodb.com>2018-11-16 18:30:48 -0500
commit26ef13f278e4d19319f11e4738e7bb0001a62d93 (patch)
tree2848f3b6a27f4873cd01d1ae1d7ee3a48a96edf7 /src/mongo/db/concurrency/lock_manager.h
parent7448559b243a6f72b0ba8a6f648c6e60dcd939e6 (diff)
downloadmongo-26ef13f278e4d19319f11e4738e7bb0001a62d93.tar.gz
SERVER-37564 Remove unused deadlock detector
Diffstat (limited to 'src/mongo/db/concurrency/lock_manager.h')
-rw-r--r--src/mongo/db/concurrency/lock_manager.h99
1 files changed, 0 insertions, 99 deletions
diff --git a/src/mongo/db/concurrency/lock_manager.h b/src/mongo/db/concurrency/lock_manager.h
index 7b137715412..75922ac7c18 100644
--- a/src/mongo/db/concurrency/lock_manager.h
+++ b/src/mongo/db/concurrency/lock_manager.h
@@ -134,9 +134,6 @@ public:
BSONObjBuilder* result);
private:
- // The deadlock detector needs to access the buckets and locks directly
- friend class DeadlockDetector;
-
// The lockheads need access to the partitions
friend struct LockHead;
@@ -219,100 +216,4 @@ private:
static const unsigned _numPartitions;
Partition* _partitions;
};
-
-
-/**
- * Iteratively builds the wait-for graph, starting from a given blocked Locker and stops either
- * when all reachable nodes have been checked or if a cycle is detected. This class is
- * thread-safe. Because locks may come and go in parallel with deadlock detection, it may
- * report false positives, but if there is a stable cycle it will be discovered.
- *
- * Implemented as a separate class in order to facilitate diagnostics and also unit-testing for
- * cases where locks come and go in parallel with deadlock detection.
- */
-class DeadlockDetector {
-public:
- /**
- * Initializes the wait-for graph builder with the LM to operate on and a locker object
- * from which to start the search. Deadlock will only be reported if there is a wait cycle
- * in which the initial locker participates.
- */
- DeadlockDetector(const LockManager& lockMgr, const Locker* initialLocker);
-
- DeadlockDetector& check() {
- while (next()) {
- }
-
- return *this;
- }
-
- /**
- * Processes the next wait for node and queues up its set of owners to the unprocessed
- * queue.
- *
- * @return true if there are more unprocessed nodes and no cycle has been discovered yet;
- * false if either all reachable nodes have been processed or
- */
- bool next();
-
- /**
- * Checks whether a cycle exists in the wait-for graph, which has been built so far. It's
- * only useful to call this after next() has returned false.
- */
- bool hasCycle() const;
-
- /**
- * Produces a string containing the wait-for graph that has been built so far.
- */
- std::string toString() const;
-
-private:
- // An entry in the owners list below means that some locker L is blocked on some resource
- // resId, which is currently held by the given set of owners. The reason to store it in
- // such form is in order to avoid storing pointers to the lockers or to have to look them
- // up by id, both of which require some form of synchronization other than locking the
- // bucket for the resource. Instead, given the resId, we can lock the bucket for the lock
- // and find the respective LockRequests and continue our scan forward.
- typedef std::vector<LockerId> ConflictingOwnersList;
-
- struct Edges {
- explicit Edges(ResourceId resId) : resId(resId) {}
-
- // Resource id indicating the lock node
- ResourceId resId;
-
- // List of lock owners/pariticipants with which the initial locker conflicts for
- // obtaining the lock
- ConflictingOwnersList owners;
- };
-
- typedef std::map<LockerId, Edges> WaitForGraph;
- typedef WaitForGraph::value_type WaitForGraphPair;
-
-
- // We don't want to hold locks between iteration cycles, so just store the resourceId and
- // the lockerId so we can directly find them from the lock manager.
- struct UnprocessedNode {
- UnprocessedNode(LockerId lockerId, ResourceId resId) : lockerId(lockerId), resId(resId) {}
-
- LockerId lockerId;
- ResourceId resId;
- };
-
- typedef std::deque<UnprocessedNode> UnprocessedNodesQueue;
-
-
- void _processNextNode(const UnprocessedNode& node);
-
-
- // Not owned. Lifetime must be longer than that of the graph builder.
- const LockManager& _lockMgr;
- const LockerId _initialLockerId;
-
- UnprocessedNodesQueue _queue;
- WaitForGraph _graph;
-
- bool _foundCycle;
-};
-
} // namespace mongo