Problem Statement
Which statement about deadlocks is correct?
Explanation
A deadlock is a cycle of waiting. Engines detect the cycle and abort one victim to break it. Your code should handle the error and retry safely.
Prevent deadlocks by acquiring resources in a consistent order, keeping transactions short, and using selective indexes to lock fewer rows.
Code Solution
SolutionRead Only
BEGIN; -- T1 locks row A then tries B -- T2 locks row B then tries A -> cycle
Practice Sets
This question appears in the following practice sets:
