| Databases InterBase (28) MS-SQL (5) mysql (35) Oracle (1) |
How can I simulate a deadlock for testing purposes?
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.
Comments:
|