Transactional Information Systems:

Slides:



Advertisements
Similar presentations
CM20145 Concurrency Control
Advertisements

1 Lecture 11: Transactions: Concurrency. 2 Overview Transactions Concurrency Control Locking Transactions in SQL.
Transaction Management: Concurrency Control CS634 Class 17, Apr 7, 2014 Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
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.
Concurrency Control and Recovery In real life: users access the database concurrently, and systems crash. Concurrent access to the database also improves.
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.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Transaction Processing: Concurrency and Serializability 10/4/05.
Transaction Management
6/25/2015Transactional Information Systems7-1 Transactional Information Systems: Theory, Algorithms, and the Practice of Concurrency Control and Recovery.
Concurrency. Correctness Principle A transaction is atomic -- all or none property. If it executes partly, an invalid state is likely to result. A transaction,
6/27/2015Transactional Information Systems8-1 Transactional Information Systems: Theory, Algorithms, and the Practice of Concurrency Control and Recovery.
GRANULARITY OF LOCKS IN SHARED DATA BASE J.N. Gray, R.A. Lorie and G.R. Putzolu.
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.
08_Transactions_LECTURE2 DBMSs should guarantee ACID properties (Atomicity, Consistency, Isolation, Durability). This is typically done by guaranteeing.
Department of Computer Science and Engineering, HKUST 1 More on Isolation.
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.
Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.
1 CSE232A: Database System Principles More Concurrency Control and Transaction Processing.
Multidatabase Transaction Management COP5711. Multidatabase Transaction Management Outline Review - Transaction Processing Multidatabase Transaction Management.
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.
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.
Chap.7 Concurrency Control Algorithms on object
Section 18.6: Managing Hierarchies of Database Elements
Concurrency Control Managing Hierarchies of Database Elements (18.6)
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 More !
Concurrency Control.
Multiple Granularity Granularity is the size of data item  allowed to lock. Multiple Granularity is the hierarchically breaking up the database into portions.
Transactional Information Systems:
Part- A Transaction Management
Chapter 6: Concurrency Control on Objects: Notions of Correctness
Distributed Transactions
Concurrency.
Chapter 10 Transaction Management and Concurrency Control
Lecture 21: Concurrency & Locking
Outline Introduction Background Distributed DBMS Architecture
Transactional Information Systems:
Chapter 15 : Concurrency Control
Transactional Information Systems:
Introduction of Week 13 Return assignment 11-1 and 3-1-5
Distributed Transactions
Chapter 2: Computational Models
Transactional Information Systems:
Transactional Information Systems
STRUCTURE OF PRESENTATION :
UNIVERSITAS GUNADARMA
Temple University – CIS Dept. CIS661 – Principles of Data Management
Transactional Information Systems:
Transaction Management Overview
Chapter 7: Concurrency Control Algorithms on Objects
Submitted to Dr. Badie Sartawi Submitted by Nizar Handal Course
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.
Transactions, Properties of Transactions
Presentation transcript:

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

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 5/15/2018 Transactional Information Systems

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) 5/15/2018 Transactional Information Systems

Reminder: Flat Object Schedule withdraw(a) withdraw(b) r(p) r(q) w(p) w(t) w(q) deposit(c) r(r) w(r) (State-independent) Commutativity table: withdraw (x,2) deposit (x,2) getbalance (x) withdraw (x,1) deposit (x,1) _ + 5/15/2018 Transactional Information Systems

2PL for Flat Object Schedules Lock acquisition rule: L1 operation f(x) needs to lock x in f mode Lock release rule: Once an L1 lock of f(x) is released, no other L1 lock can be acquired. introduce a special lock mode for each operation type derive lock compatibility from state-independent commutativity Example: Note that operations may be issued in parallel but the execution of a single operation is both sequential and uninterrupted, so as to fit the flat object definition. deposit(a) deposit(b) withdraw (c) withdraw(a) t1 t2 5/15/2018 Transactional Information Systems

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 5/15/2018 Transactional Information Systems

Transactional Information Systems Layered 2PL Lock acquisition rule: Li operation f(x) with parent p, which is now a subtransaction, needs to lock x in f mode Lock release rule: Once an Li 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 Li 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 Li operations, transactions are decomposed into sequences of independently isolated, chained subtransactions 5/15/2018 Transactional Information Systems

Transactional Information Systems 2-Level 2PL Example Here modify(y) waits until the modify(y) lock is released, apparently SS2PL (otherwise could release after modify(w) is acquired) fetch(x) modify(y) r(t) r(p) t1 t2 t11 t21 L1 L0 store(z) modify(w) r(q) w(q) w(p) w(t) t12 t13 t22 5/15/2018 Transactional Information Systems

Transactional Information Systems 3-Level Example t2 t1 Seems to be a “hypothetical execution”, not an actual one. 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, "Austin", @x) search (CityIndex, "Seattle") insert (AgeIndex, 29, @x) search (AgeIndex, 29) fetch(y) search (AgeIndex, 30) fetch(z) Note erasure r(p) w(p) r(r) r(n) r(r) r(l) r(n) w(l) r(l) r(r’) r(n’) r(l’) r(r’) r(n’) r(l’) w(l’) r(p) Note erasure r(r’) r(n’) r(l’) r(p) 5/15/2018 Transactional Information Systems

Transactional Information Systems 3-Level 2PL Example Insert Into Persons Values (Name=..., City="Austin", Age=29, ...) Select Name From Persons Where Age=30 t1 Select Name From Persons Where City="Seattle" And Age=29 Locks here are predicate locks t2 L2 No level 2 predicate conflict insert (CityIndex, "Austin", @x) insert (AgeIndex, 29, @x) A level 1 conflict search (AgeIndex, 30) store(x) fetch(z) t12 search (CityIndex, "Seattle") t11 search (AgeIndex, 29) fetch(y) L1 t21 r(p) w(p) r(r) r(n) r(l) w(l) r(r’) r(n’) r(l’) w(l’) r(r’) r(n’) r(l’) r(p) Note erasure t111 t112 t113 t121 t122 r(r) r(n) r(l) r(r’) r(n’) r(l’) r(p) L0 Note erasure t211 t212 t213 5/15/2018 Transactional Information Systems

Transactional Information Systems 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 Ln, ..., L0 apply locking on selected layers Li0, ... , Lik with 1  k  n, i0 = n, ik = 0, i > i+1, skipping all other layers 5/15/2018 Transactional Information Systems

Selective Layered 2PL Example Insert Into Persons Values (Name=..., City="Austin", Age=29, ...) Select Name From Persons Where Age=30 Select Name From Persons Where City="Seattle" And Age=29 L2 A number of errors here What about the ordering of operations in “hidden layers”? insert (CityIndex, "Austin", @x) search (AgeIndex, 30) store(x) insert (AgeIndex, 29, @x) fetch(z) search (CityIndex, "Seattle") search (AgeIndex, 29) fetch(y) L1 r(p) w(p) r(r) r(n) r(l) w(l) r(r’) r(n’) r(l’) w(l’) r(r’) r(n’) r(l’) r(p) Note erasure r(r) r(n) r(l) r(r’) r(n’) r(l’) r(p) L0 Note erasure 5/15/2018 Transactional Information Systems

Intra Transaction Parallelism Delete and Insert run in parallel by the same transaction 5/15/2018 Transactional Information Systems

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 5/15/2018 Transactional Information Systems

Transactional Information Systems Problem Scenario t1 deposit(x) incr(a) append(l) r(p) w(p) r(q) w(q) t2 decr(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) Problem: layers can be “bypassed” Solution: keep locks in “retained” mode 5/15/2018 Transactional Information Systems

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. 5/15/2018 Transactional Information Systems

Proof Sketch for Theorem 7.2 If all locks of t1 were kept until commit, then tree reducibility were trivially guaranteed. Now show that retained f1 lock by h1 is sufficient to prevent non-commutative subtree: t1 t2 h1 f1 h2 f2 ... Let f2 be the first conflict with any lock under h1; f2 is allowed to proceed only if h1 is terminated and h2 commutes with h1 isolate h2 from h1 prune h2 and h1 commute h2 with h1 if necessary 5/15/2018 Transactional Information Systems

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 5/15/2018 Transactional Information Systems

Transactional Information Systems Hybrid Algorithms Theorem 7.3: For 2-level schedules the combination of 2PL at L1 and FOCC at L0 generates only tree-reducible schedules. Theorem 7.4: For 2-level schedules the combination of 2PL at L1 and ROMV at L0 These combinations are particularly attractive because subtransactions are short and there is a large fraction of read-only subtransactions. 5/15/2018 Transactional Information Systems

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 5/15/2018 Transactional Information Systems

Locking for Return-value Commutativity introduce a special lock mode for each pair <operation type, return value>, 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 5/15/2018 Transactional Information Systems

Transactional Information Systems 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 5/15/2018 Transactional Information Systems

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; 5/15/2018 Transactional Information Systems

Escrow Locking Example decr(x,80) t1 decr(x,10) abort t2 incr(x,50) t3 decr(x,20) t4 constraint: 0  x x(0) = 100 x(4) =50 [20, 100] [10, 100] [10, 150] [10, 70] [20, 70] [0, 70] [50, 70] [x.inf, x.sup] 5/15/2018 Transactional Information Systems

Escrow Deadlock Example t1 incr(x,10) t2 t3 t4 decr(x,20) x(0) = 0 getval(y) getval(z) update(y) update(z) 5/15/2018 Transactional Information Systems

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 5/15/2018 Transactional Information Systems

Transactional Information Systems 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. 5/15/2018 Transactional Information Systems