InnoDB actively detects the deadlock and rolls back a waiting transaction. The question is, how does InnoDB detect deadlocks?
The intuitive method is that when two transactions wait for each other, when the waiting time of one transaction exceeds a set threshold, one transaction is rolled back, and the other transaction can continue to execute. This method is simple and effective. In InnoDB, the parameter InnoDB is used_ lock_ wait_ Timeout is too laggy, and if there is a lot of deadlocks, it will cause more time wasting. The system will be stuck, so analyzing deadlocks is also a very important thing.
Deadlock detection is a life-saving straw given by InnoDB when deadlock occurs. We need it, but what we need more is the ability to avoid deadlock. How can we avoid it as much as possible? This requires understanding the locks in InnoDB.
I won’t write about the cause of deadlock. Let’s go to another blog
How to find deadlock, how to avoid deadlock, which is written clearly!
This work adoptsCC agreementReprint must indicate the author and the link of this article