Carnegie Mellon Carnegie Mellon Univ. Dept. of Computer Science 15-415 - Database Applications C. Faloutsos Concurrency control.

Slides:



Advertisements
Similar presentations
CM20145 Concurrency Control
Advertisements

Database Systems (資料庫系統)
Unit 9 Concurrency Control. 9-2 Wei-Pang Yang, Information Management, NDHU Content  9.1 Introduction  9.2 Locking Technique  9.3 Optimistic Concurrency.
1 Lecture 11: Transactions: Concurrency. 2 Overview Transactions Concurrency Control Locking Transactions in SQL.
Accessing data Transactions. Agenda Questions from last class? Transactions concurrency Locking rollback.
Principles of Transaction Management. Outline Transaction concepts & protocols Performance impact of concurrency control Performance tuning.
Concurrency Control Enforcing Serializability by Locks
1 ICS 214B: Transaction Processing and Distributed Data Management Lecture 4: More on Locks Professor Chen Li.
1 CS216 Advanced Database Systems Shivnath Babu Notes 12: Concurrency Control (II)
Concurrency Control Amol Deshpande CMSC424. Approach, Assumptions etc.. Approach  Guarantee conflict-serializability by allowing certain types of concurrency.
4/16/20151 PSU’s CS Concurrency Control and Recovery (only for DBs with updates…..!)- Review  Concurrency Control  Transaction  ACID  Isolation.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Concurrency Control Chapter 17 Sections
Concurrency Control II. General Overview Relational model - SQL  Formal & commercial query languages Functional Dependencies Normalization Physical Design.
Concurrency Control Part 2 R&G - Chapter 17 The sequel was far better than the original! -- Nobody.
CMU SCS Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications C. Faloutsos – A. Pavlo Lecture#22: Concurrency Control – Part 2 (R&G.
ICS 421 Spring 2010 Transactions & Concurrency Control (i) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa.
Concurrency Control. Example Schedules Constraint: The sum of A+B must be the same Before: After: T1 read(A) A = A -50 write(A) read(B)
Concurrency Control Managing Hierarchies of Database Elements (18.6) 1 Presented by Ronak Shah (214) March 9, 2009.
Final Exam Review Last Lecture R&G - All Chapters Covered The end crowns all, And that old common arbitrator, Time, Will one day end it. William Shakespeare.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
1 Transaction Management Database recovery Concurrency control.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Concurrency Control. General Overview Relational model - SQL  Formal & commercial query languages Functional Dependencies Normalization Transaction Processing.
CMU SCS Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications C. Faloutsos – A. Pavlo Lecture#22: Concurrency Control – Part 2 (R&G.
Chapter 181 Chapter 18: Concurrency Control (Slides by Hector Garcia-Molina,
CMU SCS Carnegie Mellon Univ. Dept. of Computer Science Database Applications Concurrency Control, II (R&G ch. 17)
08_Transactions_LECTURE2 DBMSs should guarantee ACID properties (Atomicity, Consistency, Isolation, Durability). This is typically done by guaranteeing.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 10 Transaction Management.
CMU SCS Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications C. Faloutsos – A. Pavlo Lecture#21: Concurrency Control (R&G ch. 17)
V. Megalooikonomou Concurrency control (based on slides by C. Faloutsos at CMU and on notes by Silberchatz,Korth, and Sudarshan) Temple University – CIS.
1 Transactions Chapter Transactions A transaction is: a logical unit of work a sequence of steps to accomplish a single task Can have multiple.
Module Coordinator Tan Szu Tak School of Information and Communication Technology, Politeknik Brunei Semester
1 Concurrency Control II: Locking and Isolation Levels.
Chapter 20 Transaction Management Thomas Connolly, Carolyn Begg, Database System, A Practical Approach to Design Implementation and Management, 4 th Edition,
Carnegie Mellon Carnegie Mellon Univ. Dept. of Computer Science Database Applications C. Faloutsos Recovery.
1 Concurrency Control Lecture 22 Ramakrishnan - Chapter 19.
Transaction Management Overview. Transactions Concurrent execution of user programs is essential for good DBMS performance. – Because disk accesses are.
1 Advanced Database Concepts Transaction Management and Concurrency Control.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
©Bob Godfrey, 2002, 2005 Lecture 17: Transaction Integrity and Concurrency BSA206 Database Management Systems.
3 Database Systems: Design, Implementation, and Management CHAPTER 9 Transaction Management and Concurrency Control.
Jinze Liu. ACID Atomicity: TX’s are either completely done or not done at all Consistency: TX’s should leave the database in a consistent state Isolation:
CS 440 Database Management Systems Concurrency Control 1.
Prepared by: Mudra Patel (113) Pradhyuman Raol(114) Locking Scheduler & Managing Hierarchies of Database Elements.
1 Concurrency Control. 2 Why Have Concurrent Processes? v Better transaction throughput, response time v Done via better utilization of resources: –While.
CS 540 Database Management Systems Concurrency Control 1.
CS 440 Database Management Systems
Concurrency Control Techniques
Transaction Management and Concurrency Control
C. Faloutsos Concurrency control - deadlocks
Concurrency Control More !
Cse 344 March 25th – Isolation.
Transaction Management
Temple University – CIS Dept. CIS661 – Principles of Data Management
Transaction Properties
בקרת בו זמניות (concurrency control)
March 9th – Transactions
Chapter 10 Transaction Management and Concurrency Control
Lecture#21: Concurrency Control – Part 1
Introduction of Week 13 Return assignment 11-1 and 3-1-5
Concurrency Control E0 261 Prasad Deshpande, Jayant Haritsa
Transaction Management
Temple University – CIS Dept. CIS661 – Principles of Data Management
CPSC-608 Database Systems
Database Management System
C. Faloutsos Transactions
Temple University – CIS Dept. CIS616– Principles of Data Management
CONCURRENCY Concurrency is the tendency for different tasks to happen at the same time in a system ( mostly interacting with each other ) .   Parallel.
Lecture 18: Concurrency Control
Temple University – CIS Dept. CIS661 – Principles of Data Management
Presentation transcript:

Carnegie Mellon Carnegie Mellon Univ. Dept. of Computer Science Database Applications C. Faloutsos Concurrency control

Carnegie Mellon C. Faloutsos2 General Overview Relational model - SQL Functional Dependencies & Normalization Physical Design &Indexing Query optimization Transaction processing –concurrency control –recovery

Carnegie Mellon C. Faloutsos3 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

Carnegie Mellon C. Faloutsos4 Concurrency – overview why we want it? what does it mean ‘correct’ interleaving? –precedence graph how to achieve correct interleavings automatically? –concurrency control

Carnegie Mellon C. Faloutsos5 Problem concurrent access to data (consider ‘lost update’ problem) how to solve it?

Carnegie Mellon C. Faloutsos6 Read(N) Lost update problem – no locks time

Carnegie Mellon C. Faloutsos7 Solution – part 1 locks! (most popular solution) lock manager: grants/denies lock requests

Carnegie Mellon C. Faloutsos8 Lost update problem – with locks time T1 lock(N) Read(N) N=N-1 Write(N) Unlock(N) T2 lock(N) lock manager grants lock denies lock T2: waits grants lock to T2 Read(N)...

Carnegie Mellon C. Faloutsos9 Locks but, what if we all just want to read ‘N’?

Carnegie Mellon C. Faloutsos10 Solution – part 1 Locks and their flavors –exclusive (or write-) locks –shared (or read-) locks – compatibility matrix T2 wants T1 has SX S X

Carnegie Mellon C. Faloutsos11 Solution – part 1 transactions request locks (or upgrades) lock manager grants or blocks requests transactions release locks lock manager updates lock-table

Carnegie Mellon C. Faloutsos12 Solution – part 2 locks are not enough – eg., ‘inconsistent analysis’

Carnegie Mellon C. Faloutsos13 ‘Inconsistent analysis’ Precedence graph? time

Carnegie Mellon C. Faloutsos14 ‘Inconsistent analysis’ – w/ locks time T1 L(A) Read(A)... U(A) T2 L(A).... L(B).... the problem remains! Solution??

Carnegie Mellon C. Faloutsos15 General solution: Protocol(s) Most popular protocol: 2 Phase Locking (2PL)

Carnegie Mellon C. Faloutsos16 2PL X-lock version: transactions issue no lock requests, after the first ‘unlock’ THEOREM: if all transactions obey 2PL -> all schedules are serializable

Carnegie Mellon C. Faloutsos17 2PL – example ‘inconsistent analysis’ – why not 2PL? how would it be under 2PL?

Carnegie Mellon C. Faloutsos18 2PL – X/S lock version transactions issue no lock/upgrade request, after the first unlock/downgrade In general: ‘growing’ and ‘shrinking’ phase

Carnegie Mellon C. Faloutsos19 2PL – observations -limits concurrency -may lead to deadlocks -2PLC (keep locks until ‘commit’)

Carnegie Mellon C. Faloutsos20 Concurrency – overview what does it mean ‘correct’ interleaving? –precedence graph how to achieve correct interleavings automatically? concurrency control –locks + protocols 2PL, 2PLC graph protocols multiple granularity locks –

Carnegie Mellon C. Faloutsos21 Other protocols than 2-PL – graph -assumption: there is a (hierarchical) ordering on the data items, like, eg., pages of a B-tree A B C

Carnegie Mellon C. Faloutsos22 Eg., tree protocol (X-lock version) -a xact can request any item, on its first lock request -from then on, it can only request items for which it holds the parent lock -it can release locks at any time -it can NOT request an item twice

Carnegie Mellon C. Faloutsos23 Tree protocol - example T1 T2 L(B) L(D) L(H) U(D) L(E) U(E) L(D) U(B) U(H) L(G) U(D) U(G) GIH FED CB A -2PL? -‘correct’?

Carnegie Mellon C. Faloutsos24 Tree protocol -equivalent to 2PL? -deadlocks?

Carnegie Mellon C. Faloutsos25 More protocols -lock granularity – field? record? page? table? -Pros and cons? -(Ideally, each transaction should obtain a few locks)

Carnegie Mellon C. Faloutsos26 Multiple granularity Eg: attr1 attr2 record-nrecord2record1 Table2 Table1 DB

Carnegie Mellon C. Faloutsos27 what types of locks? X/S locks for leaf level + ‘intent’ locks, for higher levels IS: intent to obtain S-lock underneath IX: intent.... X-lock... S: shared lock for this level X: ex- lock for this level SIX: shared lock here; + IX

Carnegie Mellon C. Faloutsos28 Protocol -each xact obtains appropriate lock at highest level -proceeds to desirable lower levels

Carnegie Mellon C. Faloutsos29 Compatibility matrix T2 wants T1 has ISIXSSIXX IS IX S SIX X

Carnegie Mellon C. Faloutsos30 Conclusions -‘ACID’ for transactions -concurrency: -serializability (precedence graph) -one (popular) solution: locks + -2PL(C) protocol -graph protocols; multiple gran.