How can I simulate a deadlock for testing purposes?
5 comments. Current rating: (1 votes). Leave comments and/ or rate it.
Question:How can I simulate a deadlock for testing purposes?
Answer:Below is a quick recipe for a dead lock. Two transactions, one first updating table 1, then 2 and the other one doing it in reverse order.
Both transactions wait in the middle for 20 seconds to give you some time to execute them 'simulaneously'.
When you run the two in transactions in two windows 'at the same time', you'll only have to wait ~20 seconds, and one of the windows will experience a dead lock.