6/25/2015Transactional Information Systems7-1 Transactional Information Systems: Theory, Algorithms, and the Practice of Concurrency Control and Recovery.

Slides:



Advertisements
Similar presentations
CM20145 Concurrency Control
Advertisements

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.
Concurrency II. Shared/Exclusive Locks Problem: while simple locks + 2PL guarantee conflict­serializability, they do not allow two readers of DB element.
Concurrency Control Enforcing Serializability by Locks
1 CS216 Advanced Database Systems Shivnath Babu Notes 12: Concurrency Control (II)
Concurrency Control Part 2 R&G - Chapter 17 The sequel was far better than the original! -- Nobody.
Lecture 11 Recoverability. 2 Serializability identifies schedules that maintain database consistency, assuming no transaction fails. Could also examine.
Sekolah Tinggi Ilmu Statistik (STIS) 1 Dr. Said Mirza Pahlevi, M.Eng.
Concurrency Control R &G - Chapter 19 Smile, it is the key that fits the lock of everybody's heart. Anthony J. D'Angelo, The College Blue Book.
©Silberschatz, Korth and Sudarshan16.1Database System Concepts 3 rd Edition Chapter 16: Concurrency Control Lock-Based Protocols Timestamp-Based Protocols.
Distributed Systems Fall 2010 Transactions and concurrency control.
Transaction Management and Concurrency Control
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
1 Concurrency Control: 18.4 Locking Systems with Several Lock Modes CS257 Spring/2009 Professor: Tsau Lin Student: Suntorn Sae-Eung ID: 212.
Concurrency Control: 18.4 Locking Systems with Several Lock Modes CS257 Spring/2009 Professor: Tsau Lin Student: Suntorn Sae-Eung ID:
Transaction Processing: Concurrency and Serializability 10/4/05.
Transaction Management
Concurrency. Correctness Principle A transaction is atomic -- all or none property. If it executes partly, an invalid state is likely to result. A transaction,
©Silberschatz, Korth and Sudarshan16.1Database System Concepts 3 rd Edition Chapter 16: Concurrency Control Lock-Based Protocols Timestamp-Based Protocols.
7/13/2015Transactional Information Systems10-1 Transactional Information Systems: Theory, Algorithms, and the Practice of Concurrency Control and Recovery.
7/13/2015Transactional Information Systems6-1 Transactional Information Systems: Theory, Algorithms, and the Practice of Concurrency Control and Recovery.
Transaction Management and Concurrency Control
08_Transactions_LECTURE2 DBMSs should guarantee ACID properties (Atomicity, Consistency, Isolation, Durability). This is typically done by guaranteeing.
Distributed Transactions
ITEC 3220M Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220m.htm
V. Megalooikonomou Concurrency control (based on slides by C. Faloutsos at CMU and on notes by Silberchatz,Korth, and Sudarshan) Temple University – CIS.
Chapter 11 Concurrency Control. Lock-Based Protocols  A lock is a mechanism to control concurrent access to a data item  Data items can be locked in.
Concurrency Control Concurrency Control By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING COLLEGE TIRUVANNAMALAI.
1 Concurrency Control II: Locking and Isolation Levels.
Lecture 13 Advanced Transaction Models. 2 Protocols considered so far are suitable for types of transactions that arise in traditional business applications,
Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.
Lecture 8- Concurrency Control Advanced Databases Masood Niazi Torshiz Islamic Azad university- Mashhad Branch
Multidatabase Transaction Management COP5711. Multidatabase Transaction Management Outline Review - Transaction Processing Multidatabase Transaction Management.
Lecture 9- Concurrency Control (continued) Advanced Databases Masood Niazi Torshiz Islamic Azad University- Mashhad Branch
Em Spatiotemporal Database Laboratory Pusan National University File Processing : Concurrency Control 2004, Spring Pusan National University Ki-Joune Li.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 15 : Concurrency.
11th International Conference on Web-Age Information Management July 15-17, 2010 Jiuzhaigou, China V Locking Protocol for Materialized Aggregate Join Views.
Distributed Transactions What is a transaction? (A sequence of server operations that must be carried out atomically ) ACID properties - what are these.
Chapter 13 Managing Transactions and Concurrency Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
SYSTEMS IMPLEMENTATION TECHNIQUES TRANSACTION PROCESSING DATABASE RECOVERY DATABASE SECURITY CONCURRENCY CONTROL.
Transactional Information Systems:
Contents. Goal and Overview. Ingredients. The Page Model.
Transactional Information Systems:
Chap.7 Concurrency Control Algorithms on object
Transactional Information Systems - Chapter 2. ML Lab 나 용 찬
6. Concurrency Control on Objects : Notions of Correctness.
Lecture 3 Concurrency control techniques
Concurrency Control Techniques
Computational Models Database Lab Minji Jo.
Transaction Management and Concurrency Control
Concurrency Control.
Transactional Information Systems:
Chapter 6: Concurrency Control on Objects: Notions of Correctness
Chapter 10 Transaction Management and Concurrency Control
Lecture 21: Concurrency & Locking
Transactional Information Systems:
Chapter 15 : Concurrency Control
Transactional Information Systems:
Distributed Transactions
Chapter 2: Computational Models
Transactional Information Systems:
Transactional Information Systems
STRUCTURE OF PRESENTATION :
Temple University – CIS Dept. CIS661 – Principles of Data Management
Transactional Information Systems:
Chapter 7: Concurrency Control Algorithms on Objects
Transactional Information Systems:
CONCURRENCY Concurrency is the tendency for different tasks to happen at the same time in a system ( mostly interacting with each other ) .   Parallel.
Presentation transcript:

6/25/2015Transactional Information Systems7-1 Transactional Information Systems: Theory, Algorithms, and the Practice of Concurrency Control and Recovery Gerhard Weikum and Gottfried Vossen “Teamwork is essential. It allows you to blame someone else.”(Anonymous) © 2002 Morgan Kaufmann ISBN

6/25/2015Transactional Information Systems7-2 Part II: Concurrency Control 3 Concurrency Control: Notions of Correctness for the Page Model 4 Concurrency Control Algorithms 5 Multiversion Concurrency Control 6 Concurrency Control on Objects: Notions of Correctness 7 Concurrency Control Algorithms on Objects 8 Concurrency Control on Relational Databases 9 Concurrency Control on Search Structures 10 Implementation and Pragmatic Issues

6/25/2015Transactional Information Systems7-3 7 Concurrency Control Algorithms on Objects 7.2 Locking for Flat Object Transactions 7.3 Layered Locking 7.4 Locking on General Transaction Forests 7.5 Hybrid Algorithms 7.6 Locking for Return-value Commutativity 7.7 Lessons Learned “A journey of thousand miles must begin with a single step.” (Lao-tse)

6/25/2015Transactional Information Systems7-4 2PL for Flat Object Schedules deposit(a)deposit(b) withdraw (c) withdraw(a) t1t1 t2t2 Lock acquisition rule: L 1 operation f(x) needs to lock x in f mode Lock release rule: Once an L 1 lock of f(x) is released, no other L 1 lock can be acquired. introduce a special lock mode for each operation type derive lock compatibility from state-independent commutativity Example:

6/25/2015Transactional Information Systems7-5 7 Concurrency Control Algorithms on Objects 7.2 Locking for Flat Object Transactions 7.3 Layered Locking 7.4 Locking on General Transaction Forests 7.5 Hybrid Algorithms 7.6 Locking for Return-value Commutativity 7.7 Lessons Learned

6/25/2015Transactional Information Systems7-6 Layered 2PL Lock acquisition rule: L i operation f(x) with parent p, which is now a subtransaction, needs to lock x in f mode Lock release rule: Once an L i lock of f(x) with parent p is released, no other child of p can acquire any locks. Subtransaction rule: At the termination of an L i operation f(x), all L (i-1) locks acquired for children of f(x) are released. Theorem 7.1: Layered 2PL generates only tree reducible schedules. Proof: All level-to-level schedules are OCSR, hence the claim (by Theorem 6.2). Special cases: single-page subtransactions merely need latching for all-commutative L i operations, transactions are decomposed into sequences of independently isolated, chained subtransactions

6/25/2015Transactional Information Systems7-7 2-Level 2PL Example fetch(x) modify(y) r(t) r(p) t1t1 t2t2 t 11 t 21 L1L1 L0L0 store(z) modify(y) modify(w) r(q)w(q)w(p)w(t) r(t) r(p) t 12 r(t) r(p)w(p) t 13 r(t) r(p)w(p) t 22 r(t) r(p)w(p)

6/25/2015Transactional Information Systems7-8 3-Level Example t1t1 t2t2 Insert Into Persons Values (Name=..., City="Austin", Age=29,...) Select Name From Persons Where City="Seattle" And Age=29 Select Name From Persons Where Age=30 store(x) insert (CityIndex, search (CityIndex, "Seattle") insert (AgeIndex, search (AgeIndex, 29) search (AgeIndex, 30) fetch(z) r(p)w(p)r(r)r(n)r(r)r(l)r(n)w(l)r(l)r(r’)r(n’)w(l’)r(l’)r(r’)r(n’)r(l’)r(r’)r(n’)r(l’)r(p)w(p) fetch(y) r(p)w(p)

6/25/2015Transactional Information Systems7-9 3-Level 2PL Example Insert Into Persons Values (Name=..., City="Austin", Age=29,...) Select Name From Persons Where City="Seattle" And Age=29 Select Name From Persons Where Age=30 store(x) insert (CityIndex, search (CityIndex, "Seattle") insert (AgeIndex, search (AgeIndex, 30) fetch(z) r(p)w(p) t1t1 t2t2 search (AgeIndex, 29) fetch(y) t 11 t 12 t 21 t 111 r(p)w(p) t 122 r(r)r(n) t 112 r(l)w(l) r(r)r(n) t 211 r(l) r(r’)r(n’) t 121 r(l’) r(r’)r(n’)r(l’)w(l’) t 113 r(p)w(p) t 213 r(r’)r(n’) t 212 r(l’) L2L2 L0L0 L1L1

6/25/2015Transactional Information Systems7-10 Selective Layered 2PL Lock acquisition rule: Li operation f(x) with Li -1 ancestor p, which is now a subtransaction, needs to lock x in f mode Lock release rule: Once an Li lock of f(x) with Li -1 ancestor p is released, no other Li descendant of p can acquire any locks. Subtransaction rule: At the termination of an Li operation f(x), all Li +1 locks acquired for descendants of f(x) are released. For n-level schedule with layers L n,..., L 0 apply locking on selected layers Li 0,..., Li k with 1  k  n, i 0 = n, i k = 0, i > i +1, skipping all other layers

6/25/2015Transactional Information Systems7-11 Selective Layered 2PL Example Insert Into Persons Values (Name=..., City="Austin", Age=29,...) Select Name From Persons Where City="Seattle" And Age=29 Select Name From Persons Where Age=30 store(x) insert (CityIndex, search (CityIndex, "Seattle") insert (AgeIndex, search (AgeIndex, 30) fetch(z) r(p)w(p) search (AgeIndex, 29) fetch(y) r(p)w(p)r(r)r(n)r(l)w(l) r(r)r(n)r(l) r(r’) r(n’)r(l’)r(r’) r(n’)r(l’)w(l’) r(p)w(p)r(r’)r(n’) r(l’) L2 L0 L1

6/25/2015Transactional Information Systems Concurrency Control Algorithms on Objects 7.2 Locking for Flat Object Transactions 7.3 Layered Locking 7.4 Locking on General Transaction Forests 7.5 Hybrid Algorithms 7.6 Locking for Return-value Commutativity 7.7 Lessons Learned

6/25/2015Transactional Information Systems7-13 Problem Scenario t1t1 deposit(x) incr(a)append(l) r(p)w(p) r(q) w(q) deposit(y) incr(b)append(l) r(p)w(p)r(q)w(q) t2t2 decr(a)append(l) r(p)w(p)r(q)w(q)r(p)w(p)r(q)w(q) Problem: layers can be “bypassed” Solution: keep locks in “retained” mode

6/25/2015Transactional Information Systems7-14 General Object-Model 2PL Lock acquisition rule: Operation f(x) with parent p needs to lock x in f mode Lock conflict rule: A lock requested by r(x) is granted if either no conflicting lock on x is held or when for every transaction that holds a conflicting lock, say h(x), h(x) is a retained lock and r and h have ancestors r‘ and h‘ such that h‘ is terminated and commutes with r‘ Lock release rule: Once a lock of f(x) with parent p is released, no other child of p can acquire any locks. Subtransaction rule: At the termination of f(x), all locks acquired for children of f(x) are converted into retained locks. Transaction rule: At the termination of a transaction, all locks are released. Theorem 7.2: The object-model 2PL generates only tree-reducible schedules.

6/25/2015Transactional Information Systems7-15 Proof Sketch for Theorem 7.2 t1t1 t2t2 h1h1 f1f1 h2h2 f2f2... If all locks of t 1 were kept until commit, then tree reducibility were trivially guaranteed. Now show that retained f 1 lock by h 1 is sufficient to prevent non-commutative subtree: Let f 2 be the first conflict with any lock under h 1 ; f 2 is allowed to proceed only if h 1 is terminated and h 2 commutes with h 1  isolate h 2 from h 1  prune h 2 and h 1  commute h 2 with h 1 if necessary

6/25/2015Transactional Information Systems Concurrency Control Algorithms on Objects 7.2 Locking for Flat Object Transactions 7.3 Layered Locking 7.4 Locking on General Transaction Forests 7.5 Hybrid Algorithms 7.6 Locking for Return-value Commutativity 7.7 Lessons Learned

6/25/2015Transactional Information Systems7-17 Hybrid Algorithms Theorem 7.3: For 2-level schedules the combination of 2PL at L 1 and FOCC at L 0 generates only tree-reducible schedules. Theorem 7.4: For 2-level schedules the combination of 2PL at L 1 and ROMV at L 0 generates only tree-reducible schedules. These combinations are particularly attractive because subtransactions are short and there is a large fraction of read-only subtransactions.

6/25/2015Transactional Information Systems Concurrency Control Algorithms on Objects 7.2 Locking for Flat Object Transactions 7.3 Layered Locking 7.4 Locking on General Transaction Forests 7.5 Hybrid Algorithms 7.6 Locking for Return-value Commutativity 7.7 Lessons Learned

6/25/2015Transactional Information Systems7-19 Locking for Return-value Commutativity introduce a special lock mode for each pair, Example: lock modes withdraw-ok, withdraw-no, deposit-ok, getbalance-ok defer lock conflict test until end of subtransaction rollback subtransaction if lock cannot be granted and retry

6/25/2015Transactional Information Systems7-20 Escrow Locking... on bounded counter object x with lower bound low(x) and upper bound high(x) Approach: maintain infimum inf(x) and supremum sup(x) for the value of x taking into account all possible outcomes of active transactions adjust inf(x) and sup(x) upon operations incr(x), decr(x), and commit or abort of transactions

6/25/2015Transactional Information Systems7-21 Escrow Locking Pseudocode incr(x,  ): if x.sup +   x.high then x.sup := x.sup +  ; return ok else if x.inf +  > x.high then return no else wait fi fi; decr(x,  ): if x.low  x.inf -  then x.inf := x.inf -  ; return ok else if x.low > x.sup -  then return no else wait fi fi; commit(t): for each op incr(x,  ) by t do x.inf := x.inf +  od; for each op decr(x,  ) by t do x.sup := x.sup -  od; abort(t): for each op incr(x,  ) by t do x.sup := x.sup -  od; for each op decr(x,  ) by t do x.inf := x.inf +  od;

6/25/2015Transactional Information Systems7-22 Escrow Locking Example t1t1 decr(x,80) t2t2 decr(x,10) t3t3 incr(x,50) t4t4 decr(x,20) x (0) = 100x (4) =50 abort [10, 100] [10, 150] [10, 70] [20, 100] [20, 70] [0, 70] [50, 70] [x.inf, x.sup] constraint: 0  x

6/25/2015Transactional Information Systems7-23 Escrow Deadlock Example t1t1 incr(x,10) t2t2 t3t3 t4t4 decr(x,20) x (0) = 0 getval(y)getval(z) update(y) update(z)

6/25/2015Transactional Information Systems Concurrency Control Algorithms on Objects 7.2 Locking for Flat Object Transactions 7.3 Layered Locking 7.4 Locking on General Transaction Forests 7.5 Hybrid Algorithms 7.6 Locking for Return-value Commutativity 7.7 Lessons Learned

6/25/2015Transactional Information Systems7-25 Lessons Learned Layered 2PL is the fundamental protocol for industrial-strength data servers with record granularity locking (it explains the trick of “long locking” and “short latching”). This works for all kinds of ADT operations within layers; decomposed transactions with chained subtransactions (aka. “Sagas”) are simply a special case. Non-layered schedules require additional, careful locking rules. Locking on some layers can be combined with other protocols (e.g., ROMV or FOCC) on other layers. Escrow locking on counter objects is an example for additional performance enhancements by exploiting rv commutativity.