written 6.3 years ago by |
• Transaction A places an exclusive lock on item 1001
• Transaction B places an exclusive lock on item 2002
• Transaction A attempts to place an exclusive lock on item 2002
• Transaction A placed into a wait state
• Transaction B attempts to place an exclusive lock on item 1001
• Transaction B placed into a wait state
• This is called a deadlock. One transaction has locked some of the resources and is waiting for locks so it can complete.
• A second transaction has locked those needed items but is awaiting the release of locks the first transaction is holding so it can continue.
Two main ways to deal with deadlock:
a. Prevent it in the first place by giving each transaction exclusive rights to acquire all locks needed before proceeding.
b. Allow the deadlock to occur, and then break it by aborting one of the transactions.