Presentation is loading. Please wait.

Presentation is loading. Please wait.

Temple University – CIS Dept. CIS661 – Principles of Data Management

Similar presentations


Presentation on theme: "Temple University – CIS Dept. CIS661 – Principles of Data Management"— Presentation transcript:

1 Temple University – CIS Dept. CIS661 – Principles of Data Management
V. Megalooikonomou Concurrency control- Deadlocks (based on slides by C. Faloutsos at CMU and on notes by Silberchatz,Korth, and Sudarshan)

2 General Overview Relational model - SQL
Functional Dependencies & Normalization Physical Design &Indexing Query optimization Transaction processing concurrency control recovery

3 Transactions - dfn = unit of work, eg. Atomicity (all or none)
move $10 from savings to checking Atomicity (all or none) Consistency Isolation (as if alone) Durability recovery concurrency control

4 Isolation - concurrency control
serializability <-> correctness precedence graph automatically correct interleavings: locks + protocol (2PL, 2PLC) but: deadlocks!

5 Deadlocks detection handling (prevention)

6 Deadlock detection T1 T2 lock manager L(A) Yes L(B) Yes ... L(B) No
<waits> L(A) No time DEADLOCK

7 Algo for deadlock detection?
wait-for graph: nodes -> transactions arcs -> Tsource waits for Tsink if cycle, then deadlock! Must invoke a deadlock-detection algorithm periodically to look for cycles.

8 Eg: time for ‘B’ T1 T2 ‘A’ ‘B’ for ‘A’ T1 T2 lock manager L(A) Yes
L(B) Yes ... L(B) No <waits> L(A) No time for ‘B’ T1 T2 ‘A’ ‘B’ for ‘A’

9 Another example is there a deadlock? if yes, which xacts are involved?

10 Another example now, is there a deadlock?
if yes, which xacts are involved? T1 T2 T3 T4

11 Deadlock detection how often should we run the algo?
how many transactions are typically involved?

12 Deadlock handling Q: what to do? T1 T2 T3 T4

13 Deadlock handling Q0: what to do? A: select a ‘victim’ & ‘rollback’
Q1: which/how to choose? T1 T2 T3 T4

14 Deadlock handling Q1: which/how to choose? A1.1: by age
A1.2: by progress A1.3: by # items locked already... A1.4: by # xacts to rollback Q2: How far to rollback? T1 T2 T3 T4

15 Deadlock handling Q2: How far to rollback? A2.1: completely
A2.2: minimally Q3: Starvation?? T1 T2 T3 T4

16 Deadlock handling Q3: Starvation??
A3.1: include #rollbacks in victim selection criterion. T1 T2 T3 T4

17 SQL statement usually, conc. control is transparent to the user, but
LOCK <table-name> [EXCLUSIVE|SHARED]

18 Concurrency control - conclusions
serializability <-> correctness automatically correct interleavings: locks + protocol (2PL, 2PLC, ...) deadlock detection + handling

19 serializable schedules serializable schedules
Conclusions 2PL schedules serializable schedules serializable schedules 2PLC serial sch’s


Download ppt "Temple University – CIS Dept. CIS661 – Principles of Data Management"

Similar presentations


Ads by Google