![]() |
Storage Engine API
|
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. More...
#include <lock_manager.h>
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.
Classes | |
struct | Edges |
struct | UnprocessedNode |
Public Member Functions | |
DeadlockDetector (const LockManager &lockMgr, const Locker *initialLocker) | |
Initializes the wait-for graph builder with the LM to operate on and a locker object from which to start the search. More... | |
DeadlockDetector & | check () |
bool | next () |
Processes the next wait for node and queues up its set of owners to the unprocessed queue. More... | |
bool | hasCycle () const |
Checks whether a cycle exists in the wait-for graph, which has been built so far. More... | |
std::string | toString () const |
Produces a string containing the wait-for graph that has been built so far. More... | |
Private Types | |
typedef std::vector< LockerId > | ConflictingOwnersList |
typedef std::map< LockerId, Edges > | WaitForGraph |
typedef WaitForGraph::value_type | WaitForGraphPair |
typedef std::deque< UnprocessedNode > | UnprocessedNodesQueue |
Private Member Functions | |
void | _processNextNode (const UnprocessedNode &node) |
Private Attributes | |
const LockManager & | _lockMgr |
const LockerId | _initialLockerId |
UnprocessedNodesQueue | _queue |
WaitForGraph | _graph |
bool | _foundCycle |
|
private |
|
private |
|
private |
|
private |
mongo::DeadlockDetector::DeadlockDetector | ( | const LockManager & | lockMgr, |
const Locker * | initialLocker | ||
) |
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.
|
private |
|
inline |
bool mongo::DeadlockDetector::hasCycle | ( | ) | const |
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 mongo::DeadlockDetector::next | ( | ) |
Processes the next wait for node and queues up its set of owners to the unprocessed queue.
std::string mongo::DeadlockDetector::toString | ( | ) | const |
Produces a string containing the wait-for graph that has been built so far.
|
private |
|
private |
|
private |
|
private |
|
private |