MySQL 8.0.39
Source Code Documentation
|
A context of the recursive traversal through all contexts in all sessions in search for deadlock. More...
Public Member Functions | |
Deadlock_detection_visitor (MDL_context *start_node_arg) | |
bool | enter_node (MDL_context *node) override |
Enter a node of a wait-for graph. More... | |
void | leave_node (MDL_context *node) override |
Done inspecting this node. More... | |
bool | inspect_edge (MDL_context *dest) override |
Inspect a wait-for graph edge from one MDL context to another. More... | |
MDL_context * | get_victim () const |
Public Member Functions inherited from MDL_wait_for_graph_visitor | |
virtual | ~MDL_wait_for_graph_visitor () |
MDL_wait_for_graph_visitor () | |
Private Member Functions | |
void | opt_change_victim_to (MDL_context *new_victim) |
Change the deadlock victim to a new one if it has lower deadlock weight. More... | |
Private Attributes | |
MDL_context * | m_start_node |
The context which has initiated the search. More... | |
MDL_context * | m_victim |
If a deadlock is found, the context that identifies the victim. More... | |
uint | m_current_search_depth |
Set to the 0 at start. More... | |
bool | m_found_deadlock |
true if we found a deadlock. More... | |
Static Private Attributes | |
static const uint | MAX_SEARCH_DEPTH = 32 |
Maximum depth for deadlock searches. More... | |
Additional Inherited Members | |
Public Attributes inherited from MDL_wait_for_graph_visitor | |
uint | m_lock_open_count |
XXX, hack: During deadlock search, we may need to inspect TABLE_SHAREs and acquire LOCK_open. More... | |
A context of the recursive traversal through all contexts in all sessions in search for deadlock.
|
inline |
|
overridevirtual |
Enter a node of a wait-for graph.
After a node is entered, inspect_edge() will be called for all wait-for destinations of this node. Then leave_node() will be called. We call "enter_node()" for all nodes we inspect, including the starting node.
true | Maximum search depth exceeded. |
false | OK. |
Implements MDL_wait_for_graph_visitor.
|
inline |
|
overridevirtual |
Inspect a wait-for graph edge from one MDL context to another.
true | A loop is found. |
false | No loop is found. |
Implements MDL_wait_for_graph_visitor.
|
overridevirtual |
Done inspecting this node.
Decrease the search depth. If a deadlock is found, and we are backtracking to the start node, optionally change the deadlock victim to one with lower deadlock weight.
Implements MDL_wait_for_graph_visitor.
|
private |
Change the deadlock victim to a new one if it has lower deadlock weight.
new_victim | New candidate for deadlock victim. |
|
private |
Set to the 0 at start.
Increased whenever we descend into another MDL context (aka traverse to the next wait-for graph node). When MAX_SEARCH_DEPTH is reached, we assume that a deadlock is found, even if we have not found a loop.
|
private |
true if we found a deadlock.
|
private |
The context which has initiated the search.
There can be multiple searches happening in parallel at the same time.
|
private |
If a deadlock is found, the context that identifies the victim.
|
staticprivate |
Maximum depth for deadlock searches.
After this depth is achieved we will unconditionally declare that there is a deadlock.
TODO: Find out what is the optimal value for this parameter. Current value is safe, but probably sub-optimal, as there is an anecdotal evidence that real-life deadlocks are even shorter typically.