Deadlock Handling and Prevention in Database Systems: An Overview, Slides of Fundamentals of E-Commerce

Various techniques for handling and preventing deadlocks in database systems. Topics include the concept of deadlock, the impact of transactions on each other, and methods for choosing a victim transaction. Techniques covered include the 'youngest' algorithm, 'cheapest' transaction abort, and distributed deadlock handling. The document also previews upcoming topics in the series, including locking performance and multigranularity locking.

Typology: Slides

2012/2013

Uploaded on 07/29/2013

satinder
satinder 🇮🇳

4.2

(21)

131 documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Cyclic Restart
Transactions can cause each other to abort forever.
T1 starts running. Then T2 starts running.
They deadlock and T1 (the oldest) is aborted.
T1 restarts, bumps into T2 and again deadlocks
T2 (the oldest) is aborted ...
Choosing the youngest in a cycle as victim avoids
cyclic restart, since the oldest running transaction is
never the victim.
Can combine with other heuristics, e.g. fewest-locks
Docsity.com
pf3
pf4
pf5
pf8

Partial preview of the text

Download Deadlock Handling and Prevention in Database Systems: An Overview and more Slides Fundamentals of E-Commerce in PDF only on Docsity!

Cyclic Restart

Transactions can cause each other to abort forever.

T 1 starts running. Then T 2 starts running. - They deadlock and T 1 (the oldest) is aborted. - T 1 restarts, bumps into T 2 and again deadlocks - T 2 (the oldest) is aborted ... - Choosing the youngest in a cycle as victim avoidscyclic restart, since the oldest running transaction isnever the victim. - Can combine with other heuristics, e.g. fewest-locks

MS SQL Server

Aborts the transaction that is “cheapest” to rollback.

“Cheapest” is determined by the amount of loggenerated. - Allows transactions that you’ve invested a lot in tocomplete. - SET DEADLOCK_PRIORITY LOW(vs. NORMAL) causes a transaction to sacrificeitself as a victim.

Distributed Deadlock

The deadlock spans two nodes.Neither node alone can see it.

  • Timeout-based detection is popular. Its weaknesses are less important in the distributed case: - aborts unnecessarily and some deadlocks persist too long– possibly abort younger unblocked transaction to avoid cyclic restart rl 1 [x] wl 2 [x] (blocked) Node 1 rl 2 [y] wl 1 [y] (blocked) Node 2

Oracle Deadlock Handling

Uses a waits-for graph for single-serverdeadlock detection.

The transaction that detects the deadlock isthe victim. - Uses timeouts to detect distributed deadlocks.

What’s Coming in Part Two?

Locking Performance

A more detailed look at multigranularitylocking - Hot spot techniques - Query-Update Techniques - Phantoms - B-Trees and Tree locking

Locking Performance

The following is oversimplified. We’ll revisit it.

Deadlocks are rare. - Typically 1-2% of transactions deadlock. - Locking performance problems are not rare. - The problem is too much blocking. - The solution is to reduce the “locking load” - Good heuristic – If more than 30% of transactionsare blocked, then reduce the number ofconcurrent transactions