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

Slides:



Advertisements
Similar presentations
Cs4432concurrency control1 CS4432: Database Systems II Lecture #21 Concurrency Control : Theory Professor Elke A. Rundensteiner.
Advertisements

Database Systems (資料庫系統)
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.
Cs4432concurrency control1 CS4432: Database Systems II Lecture #22 Concurrency Control Professor Elke A. Rundensteiner.
Cs4432concurrency control1 CS4432: Database Systems II Lecture #22 Concurrency Control: Locking-based Protocols Professor Elke A. Rundensteiner.
Concurrency Control Part 2 R&G - Chapter 17 The sequel was far better than the original! -- Nobody.
1 CS216 Advanced Database Systems Shivnath Babu Notes 11: Concurrency Control.
C ONCURRENCY C ONTROL ON R ELATIONAL D ATABASES Seminar: Transaction Processing (Bachelor) SS 2009 Dennis Stratmann.
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez-Martínez Electrical and Computer Engineering Department Lecture 16 – Intro. to Transactions.
Cs44321 CS4432: Database Systems II Lecture #19 Database Consistency and Transactions Professor Elke A. Rundensteiner.
ICS 421 Spring 2010 Transactions & Concurrency Control (i) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa.
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.
1 Concurrency Control and Recovery Module 6, Lecture 1.
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.
Concurrency. Busy, busy, busy... In production environments, it is unlikely that we can limit our system to just one user at a time. – Consequently, it.
Transaction Processing: Concurrency and Serializability 10/4/05.
Concurrency. Correctness Principle A transaction is atomic -- all or none property. If it executes partly, an invalid state is likely to result. A transaction,
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 16.
Chapter 181 Chapter 18: Concurrency Control (Slides by Hector Garcia-Molina,
CIS 720 Concurrency Control. Locking Atomic statement –Can be used to perform two or more updates atomically Th1: …. ;……. Th2:…………. ;…….
CS 162 Discussion Section Week 9 11/11 – 11/15. Today’s Section ●Project discussion (5 min) ●Quiz (10 min) ●Lecture Review (20 min) ●Worksheet and Discussion.
Department of Computer Science and Engineering, HKUST 1 More on Isolation.
Concurrency Control R &G - Chapter 19. Transactions Concurrent execution of user programs is essential for good DBMS performance. – Because disk accesses.
1 Concurrency Control II: Locking and Isolation Levels.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 136 Database Systems I SQL Modifications and Transactions.
©Silberschatz, Korth and Sudarshan15.1Database System Concepts Chapter 15: Transactions Transaction Concept Transaction State Implementation of Atomicity.
Transactions. What is it? Transaction - a logical unit of database processing Motivation - want consistent change of state in data Transactions developed.
Sekolah Tinggi Ilmu Statistik (STIS) 1 Dr. Said Mirza Pahlevi, M.Eng.
ICS 321 Fall 2011 The Database Language SQL (iv) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 10/26/20111Lipyeow.
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 Database Systems ( 資料庫系統 ) December 27, 2004 Chapter 17 By Hao-hua Chu ( 朱浩華 )
1 Advanced Database Concepts Transaction Management and Concurrency Control.
1 Controlled concurrency Now we start looking at what kind of concurrency we should allow We first look at uncontrolled concurrency and see what happens.
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez-Martínez Electrical and Computer Engineering Department Lecture 16 – Intro. to Transactions.
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:
6/18/2016Transactional Information Systems3-1 Part II: Concurrency Control 3 Concurrency Control: Notions of Correctness for the Page Model 4 Concurrency.
1 Concurrency Control. 2 Why Have Concurrent Processes? v Better transaction throughput, response time v Done via better utilization of resources: –While.
Transactional Information Systems:
Contents. Goal and Overview. Ingredients. The Page Model.
Chapter 8: Concurrency Control on Relational Databases
8. Concurrency Control on Relational Database
Computational Models Database Lab Minji Jo.
Transaction Management Overview
Chap. 3 Concurrency Control (covering 3.8 ~ 3.11)
CS216: Data-Intensive Computing Systems
Transactional Information Systems:
Transaction Management
Transaction Management Overview
March 21st – Transactions
Transaction Management
Transaction Management Overview
Transactional Information Systems:
Concurrency Control Chapter 17
Lecture 21: Concurrency & Locking
Transactional Information Systems:
Concurrency Control Chapter 17
Transaction Management Overview
Lecture 22: Intro to Transactions & Logging IV
Transaction management
Transaction Management
Temple University – CIS Dept. CIS661 – Principles of Data Management
Transaction Management Overview
C. Faloutsos Transactions
Transactional Information Systems:
Database Systems (資料庫系統)
Database Systems (資料庫系統)
Transaction Management Overview
Presentation transcript:

6/27/2015Transactional Information Systems8-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/27/2015Transactional Information Systems8-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/27/2015Transactional Information Systems8-3 Chapter 8: Concurrency Control on Relational Databases 8.2 Predicate-Oriented Concurrency Control 8.3 Relational Update Transactions 8.4 Exploiting Transaction-Program Knowledge 8.5 Lessons Learned “Knowledge without wisdom is a load of books on the back of an ass.” (Japanese proverb)

6/27/2015Transactional Information Systems8-4 Relational Databases Database consists of tables Operations on tables and databases are –Queries (select-from-where expressions) –Insertions –Deletions –Modifications Queries and updates use (single or sets of) predicates or conditions (where clause) Sets C of conditions span hyperplanes H(C) of tuples Hyperplanes can be subject to locking

6/27/2015Transactional Information Systems8-5 Phantom Problem Emp Jones Service Clerk Meier Service Clerk Paulus Service Manager Smyth Toys Cashier Brown Sales Clerk Albert Sales Manager Name Department Position Salary Update transaction t: (a)Delete From Emp Where Department = ‘Service’ And Position = ‘Manager’ (b)Insert Into Emp Values (‘Smith’, ‘Service’, ‘Manager’, 40000) (c)Update Emp Set Department = ‘Sales’ Where Department = ‘Service’ And Position <> ‘Manager’ (d)Insert Into Emp Values (‘Stone’, ‘Service’, ‘Clerk’, 13000) Retrieval transaction q: Select Name, Position, Salary From Emp Where Department = ‘Service’ Observations: Interleaving q with t leads to inconsistent read known as “phantom problem” Locking existing records cannot prevent this problem Retrieval transaction p: Select Name, Position, Salary From Emp Where Department = ‘Sales’ Example 8.1

6/27/2015Transactional Information Systems8-6 Predicate Locking Associate with each operation on table R(A 1,..., A n ) a set C of conditions that covers a set H(C) of – existing or conceivable – tuples with H(C) = {   dom(A 1 ) ...  dom(A n ) |  satisfies C} Each operation locks its H(C) [ Update operations need to lock pre- and postcondition H(C) and H(C‘) ] Example 8.2: C a : Department = ‘Service’  Position = ‘Manager’ C b : Name=‘Smith’  Department=‘Service’  Position=‘Manager’  Salary=40000 C c : Department = ‘Service’  Position  ‘Manager’ C c ‘: Department = ‘Sales’  Position  ‘Manager’ C d : Name=‘Stone’  Department=‘Service’  Position=‘Clerk’  Salary=13000 C q : Department = ‘Service’ C p : Department = ‘Sales’ H(C a )  H(C q ) , H(C b )  H(C q ) , H(C c )  H(C q ) , H(C d )  H(C q )  H(C c ‘)  H(C q )=  H(C a )  H(C p )=H(C b )  H(C p )=H(C c )  H(C p )=H(C d )  H(C p )=  H(C c ‘)  H(C p ) 

6/27/2015Transactional Information Systems8-7 Precision Locking Predicate locks on predicates C t and C t ‘ on behalf of transactions t and t‘ in modes m t and m t ‘ are compatible if t = t‘ or both m t and m t ‘ are read (shared) mode or H(C t )  H(C t ‘) =  Testing whether H(C t )  H(C t ‘) =  is NP-complete For preventing the phantom problem it is sufficient that queries lock predicates and insert, update, and delete operations lock individual records, and compatibility is checked by testing that an update-affected record does not satisfy any of the query predicate locks

6/27/2015Transactional Information Systems8-8 8 Concurrency Control on Relational Databases 8.2 Predicate-Oriented Concurrency Control 8.3 Relational Update Transactions 8.4 Exploiting Transaction-Program Knowledge 8.5 Lessons Learned

6/27/2015Transactional Information Systems8-9 Idea Transactions are sequences of insert, delete, or modify operations (in the style of SQL updates) Define notions of serializability along the lines of the classical ones The semantic information available on transaction effects can be exploited to allow more concurrency Additional concurrency can be allowed by using dependency information, in particular FDs

6/27/2015Transactional Information Systems8-10 Transaction Syntax and Semantics Definition 8.1 (IDM Transaction): An IDM transaction over a database schema D is a finite sequence of update operations (insertions, deletions, modifications) over D. If t = u 1... u m is an IDM transaction over a given database, the effect of t, eff(t), is defined as eff(t) := eff[u 1 ] °... ° eff[u m ] Insertion:expression of the form i R (C), where C specifies a tuple over R Deletion:expression of the form d R (C), where C is a set of conditions Modification:expression of the form m R (C 1 ; C 2 ) (tuples satisfying C 1 are modified so that they satisfy C 2 )

6/27/2015Transactional Information Systems8-11 Transaction Equivalence Definition 8.2 (Transaction Equivalence): Two IDM transactions over the same database schema are equivalent, written t  t‘, if eff(t) = eff(t‘), i.e., t and t‘ have the same effect. Transaction equivalence can be decided in polynomial time: using a graphical illustration of transaction effects (“transition specs“) using a sound and complete axiomatization of “  “ We look at the latter (but only at some of the relevant rules)

6/27/2015Transactional Information Systems8-12 Commutativity Rules Let C 1, C 2, C 3, C 4 be sets of conditions describing pairwise disjoint hyperplanes: 1.i(C 1 ) i(C 2 )  i(C 2 ) i(C 1 ) 2.d(C 1 ) d(C 2 )  d(C 2 ) d(C 1 ) 3.d(C 1 ) i(C 2 )  i(C 2 ) d(C 1 )if C 1 <> C 2 4.m(C 1 ; C 2 ) m(C 3 ; C 4 )  m(C 3 ; C 4 ) m(C 1 ; C 2 ) if C 3 <> C 1, C 2 and C 1 <> C 4 5.m(C 1 ; C 2 ) i(C 3 )  i(C 3 ) m(C 1 ; C 2 ) if C 1 <> C 3 6.m(C 1 ; C 2 ) d(C 3 )  d(C 3 ) m(C 1 ; C 2 ) if C 3 <> C 1, C 2

6/27/2015Transactional Information Systems8-13 Simplification Rules 1.i(C 1 ) i(C 1 ) => i(C 1 ) 2.d(C 1 ) d(C 1 ) => d(C 1 ) 3.i(C 1 ) d(C 1 ) => d(C 1 ) 4.d(C 1 ) i(C 1 ) => i(C 1 ) 5.m(C 1 ; C 1 ) =>  6.m(C 1 ; C 2 ) i(C 2 ) => d(C 1 ) i(C 2 ) Let C 1, C 2, C 3, be sets of conditions describing pairwise disjoint hyperplanes: 7.i(C 1 ) m(C 1 ; C 2 ) => m(C 1 ; C 2 ) i(C 2 ) 8.m(C 1 ; C 2 ) d(C 1 ) => m(C 1 ; C 2 ) 9.m(C 1 ; C 2 ) d(C 2 ) => d(C 1 ) d(C 2 ) 10.d(C 1 ) m(C 1 ; C 2 ) => d(C 1 ) 11.m(C 1 ; C 2 ) m(C 1 ; C 3 ) => m(C 1 ; C 2 ) if C 1 <> C 2 12.m(C 1 ; C 2 ) m(C 2 ; C 3 ) => m(C 1 ; C 3 ) m(C 2 ; C 3 ) These rules can be used for transaction optimization.

6/27/2015Transactional Information Systems8-14 Final State Serializability Definition 8.3 (Final State Serializability): A history s for a set T = { t 1,... t n } of IDM transactions is final state serializable if s  s‘ for some serial history s‘ for T. Let FSR IDM denote the class of all final state serializable histories (for T). Example 8.3/4: Let t 1 = d(3) m(1; 2) m(3; 4),t 2 = d(3) m(2; 3) and considers = d 2 (3) d 1 (3) m 1 (1; 2) m 2 (2; 3) m 1 (3; 4) s is neither equivalent to t 1 t 2 nor to t 2 t 1 ; thus, s is not in FSR IDM However, optimizing t 1 to d(3) m(1; 2) yields s‘ = d 2 (3) d 1 (3) m 1 (1; 2) m 2 (2; 3)  t 1 t 2

6/27/2015Transactional Information Systems8-15 Testing Membership in FSR IDM Theorem 8.1: The problem of testing whether a given history is in FSR IDM is NP complete. Thus, “exact“ testing is no easier than for page model transactions when semantic information is present.

6/27/2015Transactional Information Systems8-16 Conflict Serializability Definition 8.4 (Conflict Serializability): A history s for a set T of n transactions is conflict serializable if the equivalence of s to a serial history can be proven using the commutativity rules alone. Let CSR IDM denote the class of all conflict serializable histories (for T). Definition 8.5 (Conflict Graph): Let T be a set of IDM transactions and s a history for T. The conflict graph G(s) = (T, E) of s is defined by: (t i, t j ) is in E if for transactions t i and t j in V, i <> j, there is an update u in t i and an update u‘ in t j s.t. u < s u‘ and uu‘ is not equivalent to u‘u (i.e., uu‘  u‘u does not hold). Theorem 8.2: Let s be a history for a set T of transactions. Then s is in CSR IDM iff G(s) is acyclic.

6/27/2015Transactional Information Systems8-17 Example 8.6 Considers = m 2 (1; 2) m 1 (2; 3) m 2 (3; 2) G(s) is cyclic, so s is not in CSR IDM On the other hand, s  m 1 (2; 3) m 2 (1; 2) m 2 (3; 2)  t 1 t 2 so s is in FSR IDM Consequence: CSR IDM is a strict subset of FSR IDM t1t1 t2t2

6/27/2015Transactional Information Systems8-18 Extended Conflict Serializability Definition 8.6 (Extended Conflict Graph / Serializability): Let s be a history for a set T = { t 1,... t n } of transactions. (i)The extended conflict graph EG(s) = (T, E) of s is defined by: (t i, t j ) is in E if there is an update u in t j s.t. s = s‘ u s‘‘ and u does not commute with the projection of s‘ onto t i. (ii)s is extended conflict serializable if EG(s) is acyclic. Let ECSR IDM denote the class of all extended conflict serializable histories. Sometimes, the context in which a conflict occurs can make a difference: Example: Let s = d 1 (0) m 1 (0; 1) m 2 (1; 2) m 1 (2; 3) G(s) is cyclic, but s  m 2 (1; 2) d 1 (0) m 1 (0; 1) m 1 (2; 3)  t 2 t 1 Intutively, the conflict involving m 1 (0; 1) does not exist (due to d 1 (0) ) !

6/27/2015Transactional Information Systems8-19 Relationship between the Classes Theorem 8.3: CSR IDM  ECSR IDM  FSR IDM. CSR IDM ECSR IDM FSR IDM

6/27/2015Transactional Information Systems8-20 Serializability w/ Functional Dependencies Consider a relation with attributes A and B s.t. A -> B holds, and the following history: s = m 1 (A=0, B=0; A=0, B=2) m 2 (A=0, B=0; A=0, B=3) m 2 (A=0, B=1; A=0, B=3) m 1 (A=0, B=1; A=0, B=2) s is in neither of CSR IDM, ECSR IDM, FSR IDM. However, the first conflict affects (0,0), while the second affects (0,1), and these two tuples cannot occur simultaneously in a relation satisfying the given FD! So depending on the state, s  t 1 t 2 or s  t 2 t 1.

6/27/2015Transactional Information Systems Concurrency Control on Relational Databases 8.2 Predicate-Oriented Concurrency Control 8.3 Relational Update Transactions 8.4 Exploiting Transaction-Program Knowledge 8.5 Lessons Learned

6/27/2015Transactional Information Systems8-22 Motivation: Short Transactions Are Good decompose ? t 11 : r(A 1 )w(A 1 ) t 12 : r(B 1 )w(B 1 ) t 21 : r(A 3 )w(A 3 ) t 22 : r(B 1 )w(B 1 ) t 31 : r(A 4 )w(A 4 ) t 32 : r(B 2 )w(B 2 ) t 61 : r(A 1 )r(A 2 )r(A 3 )r(B 1 ) t 62 : r(A 4 )r(A 5 )r(B 2 ) Debit/credit: t 1 : r(A 1 )w(A 1 )r(B 1 )w(B 1 ) t 2 : r(A 3 )w(A 3 )r(B 1 )w(B 1 ) t 3 : r(A 4 )w(A 4 )r(B 2 )w(B 2 ) Balance: t 4 : r(A 2 ) t 5 : r(A 4 ) Audit: t 6 : r(A 1 )r(A 2 )r(A 3 )r(B 1 )r(A 4 )r(A 5 )r(B 2 ) Example 8.12:

6/27/2015Transactional Information Systems8-23 Transaction Chopping Assumption: all potentially concurrent app programs are known in advance and their structure and resulting access patterns can be precisely analyzed Definition 8.8 (Transaction Chopping): A chopping of transaction t i is a decomposition of t i into pieces t i1,..., t ik s.t. every step of t i is contained in exactly one piece and the step order is preserved. Definition 8.10 (Correct Chopping): A chopping of T={t 1,..., t n } is correct if every execution of the transaction pieces is conflict-equivalent to a serial history of T under a protocol with transaction pieces obey the execution precedences of the original programs. each piece is executed as a unit under a CSR scheduler.

6/27/2015Transactional Information Systems8-24 Chopping Graph Definition 8.9 (Chopping Graph): For a chopping of transaction set T the chopping graph C(T) is an undirected graph s.t. the nodes of C(T) are the transaction pieces for two pieces p, q from different transactions C(T) contains a c edge between p and p‘ if p and q contain conflicting operations for two pieces p, q from the same transaction C(T) contains an s edge Theorem 8.5: A chopping is correct if the associated chopping graph does not contain an sc cycle (i.e., a cycle that involves at least one s edge and at least one c edge. Example 8.13: t 1 = r(x)w(x)r(y)w(y) t 2 = r(x)w(x) t 3 = r(y)w(y) t 11 = r(x)w(x) t 12 = r(y)w(y) t 11 t 12 t2t2 t3t3 s cc C(T):

6/27/2015Transactional Information Systems8-25 Chopping Example 8.14 t 1 : r(A 1 )w(A 1 )r(B 1 )w(B 1 ) t 2 : r(A 3 )w(A 3 )r(B 1 )w(B 1 ) t 3 : r(A 4 )w(A 4 )r(B 2 )w(B 2 ) t 4 : r(A 2 ) t 5 : r(A 4 ) t 6 : r(A 1 )r(A 2 )r(A 3 )r(B 1 )r(A 4 )r(A 5 )r(B 2 ) t 61 : r(A 1 )r(A 2 )r(A 3 )r(B 1 ) t 62 : r(A 4 )r(A 5 )r(B 2 ) t1t1 t2t2 t3t3 t4t4 t5t5 t 61 t 62 c cc c c s t 11 : r(A 1 )w(A 1 ) t 12 : r(B 1 )w(B 1 ) t 12 t2t2 t3t3 t4t4 t5t5 t 61 t 62 c cc c c s t 11 c s

6/27/2015Transactional Information Systems8-26 Applicability of Chopping Directly applicable to straight-line, parameter-less SQL programs with predicate locking Needs to conservatively derive covering program for parameterized SQL, if-then-else and loops, and needs to be conservative about c edges Example: Select AccountNo From Accounts Where AccountType=‚savings‘ And City = :x; if not found then Select AccountNo From Accounts Where AccountType=‚checking‘ And City = :x fi;  Select AccountNo From Accounts Where AccountType=‚savings‘; Select AccountNo From Accounts Where AccountType=‚checking‘;

6/27/2015Transactional Information Systems Concurrency Control on Relational Databases 8.2 Predicate-Oriented Concurrency Control 8.3 Relational Update Transactions 8.4 Exploiting Transaction-Program Knowledge 8.5 Lessons Learned

6/27/2015Transactional Information Systems8-28 Lessons Learned Predicate locking is an elegant method for concurrency control on relational databases, but has non-negligible overhead  record locking (plus index key locking) for 2-level schedules remains the practical method of choice Concurrency control may exploit additional knowledge about limited operation types, integrity constraints, and program structure Transaction chopping is an interesting tuning technique that aims to exploit such knowledge