1 / 23

Carnegie Mellon Univ. Dept. of Computer Science 15-415 - Database Applications

Carnegie Mellon Univ. Dept. of Computer Science 15-415 - Database Applications. C. Faloutsos Concurrency control - deadlocks. General Overview. Relational model - SQL Functional Dependencies & Normalization Physical Design &Indexing Query optimization Transaction processing

cmoran
Download Presentation

Carnegie Mellon Univ. Dept. of Computer Science 15-415 - Database Applications

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Carnegie Mellon Univ.Dept. of Computer Science15-415 - Database Applications C. Faloutsos Concurrency control - deadlocks

  2. General Overview • Relational model - SQL • Functional Dependencies & Normalization • Physical Design &Indexing • Query optimization • Transaction processing • concurrency control • recovery 15-415 - C. Faloutsos

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

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

  5. Deadlocks • detection • handling • (prevention) 15-415 - C. Faloutsos

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

  7. Algo for deadlock detection? 15-415 - C. Faloutsos

  8. Algo for deadlock detection? • wait-for graph: • nodes -> transactions • arcs -> Tsource waits for Tsink • if cycle, then deadlock! 15-415 - C. Faloutsos

  9. Eg: time T1 T2 lock manager L(A) Yes L(B) Yes ... L(B) No <waits> L(A) No for ‘B’ T1 T2 ‘A’ ‘B’ for ‘A’ 15-415 - C. Faloutsos

  10. T1 T2 T4 T3 Another example • is there a deadlock? • if yes, which xacts are involved? 15-415 - C. Faloutsos

  11. T1 T2 T4 T3 Another example • now, is there a deadlock? • if yes, which xacts are involved? 15-415 - C. Faloutsos

  12. Deadlock detection • how often should we run the algo? • how many transactions are typically involved? 15-415 - C. Faloutsos

  13. T1 T2 T4 T3 Deadlock handling • Q: what to do? 15-415 - C. Faloutsos

  14. T1 T2 T4 T3 Deadlock handling • Q0: what to do? • A: select a ‘victim’ & ‘rollback’ • Q1: which/how to choose? 15-415 - C. Faloutsos

  15. T1 T2 T4 T3 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? 15-415 - C. Faloutsos

  16. T1 T2 T4 T3 Deadlock handling • Q2: How far to rollback? • A2.1: completely • A2.2: minimally • Q3: Starvation?? 15-415 - C. Faloutsos

  17. T1 T2 T4 T3 Deadlock handling • Q3: Starvation?? • A3.1: include #rollbacks in victim selection criterion. 15-415 - C. Faloutsos

  18. SQL statement • usually, conc. control is transparent to the user, but • LOCK <table-name> [EXCLUSIVE|SHARED] 15-415 - C. Faloutsos

  19. Concurrency control - conclusions • serializability <-> correctness • automatically correct interleavings: • locks + protocol (2PL, 2PLC, ...) • deadlock detection + handling 15-415 - C. Faloutsos

  20. Quiz: • is there a serial schedule (= interleaving) that is not serializable? • is there a serializable schedule that is not serial? • can 2PL produce a non-serializable schedule? (assume no deadlocks) 15-415 - C. Faloutsos

  21. Quiz - cont’d • is there a serializable schedule that can not be produced by 2PL? • a xact obeys 2PL - can it be involved in a non-serializable schedule? • all xacts obey 2PL - can they end up in a deadlock? 15-415 - C. Faloutsos

  22. Quiz - hints: Q: 2PLC?? serializable schedules serializable schedules 2PL schedules serial sch’s 15-415 - C. Faloutsos

  23. Quiz - hints: 2PL schedules serializable schedules serializable schedules 2PLC serial sch’s 15-415 - C. Faloutsos

More Related