Download presentation
Presentation is loading. Please wait.
Published byJulius Perry Modified over 6 years ago
1
Chapter 8: Concurrency Control on Relational Databases
최병준
2
Outline Goal and Overview
Examine Three Approaches to Concurrency Control on Relational Databases: 1. Predicate-Oriented Concurrency Control 2. Relational Update Transactions Syntax and Semantics Histories and Final State Serializability Conflict Serializability Extended Conflict Serializability 3. Exploiting Transaction Program Knowledge Transaction Chopping Applicability of Chopping Summary Concurrency Control on Relational Databases
3
Goal and Overview Semantic approach to Concurrency Control
Possible to exploit semantic knowledge at higher abstraction level Three Approaches to Concurrency Control on Relational Databases Predicate-Oriented Concurrency Control Relational Update Transactions Exploiting Transaction Program Knowledge Hardly of practical relevance Efficient implementation is difficult to achieve Semantics is more complex than syntax Concurrency Control on Relational Databases
4
1. Predicate-Oriented Concurrency Control
Relational Databases Database consists of tables Relation (r) : table Schema (R) : table header Attributes (A1, A2, … , An) : columns Finite domain dom(Ai) Tuples : elements of r ⊆ dom(A1) x … dom(An) Operations on tables and databases are Queries (select-from-where expressions) Insertions Deletions Modifications Two Locking for transactional access on relational database Lock entire relations Prevents simultaneously accessing an subset of tuples from relation, unnecessary delays Lock individual tuples Large number of locks may result (lock administration problem, phantom problem) Concurrency Control on Relational Databases
5
1. Predicate-Oriented Concurrency Control
Phantom problem Example 8.1 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 ☞ Phantom problem : The query could no longer lock, because tuples have been deleted or are not yet existing but will be inserted in the future Concurrency Control on Relational Databases
6
1. Predicate-Oriented Concurrency Control
Predicate Locking Hyperplane Associate with each operation on table R(A1, ..., An) a set C of conditions that covers a set H(C) of – existing or conceivable – tuples with Each operation locks its H(C) Compatibility Predicate locks on predicates Ct and Ct‘ on behalf of transactions t and t‘ in modes mt and mt‘ are compatible if t = t‘ or both mt and mt‘ are read (shared) mode or H(Ct) ∩ H(Ct‘) = Φ Concurrency Control on Relational Databases
7
1. Predicate-Oriented Concurrency Control
Example 8.2 Testing whether H(Ct) ∩ H(Ct‘) = Φ 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 Concurrency Control on Relational Databases
8
2. Relational Update Transactions
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 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 is an IDM transaction over a given database, the effect of , , is defined as ☞ Effect : Semantics of the update operations Concurrency Control on Relational Databases
9
2. Relational Update Transactions
Transaction Equivalence Commutativity Rules Two update operations commute if they refer to distinct tuples Definition 8.2 (Transaction Equivalence): Two IDM transactions over the same database schema are equivalent, written , if , i.e., and have the same effect. Concurrency Control on Relational Databases
10
2. Relational Update Transactions
Simplification Rules Simplification rules can be used for transaction optimization. Concurrency Control on Relational Databases
11
2. Relational Update Transactions
Final State Serializability Improve histories by removing redundant updates or simplifying individual transactions. Definition 8.3 (Final State Serializability): A history s for a set of IDM transactions is final state serializable if for some serial history for T. Let FSRIDM denote the class of all final state serializable histories (for ). Concurrency Control on Relational Databases
12
2. Relational Update Transactions
Testing Membership in FSRIDM Thus, “exact“ testing is no easier than for page model transactions when semanti c information is present. Theorem 8.1: The problem of testing whether a given history is in FSRIDM is NP complete. Concurrency Control on Relational Databases
13
2. Relational Update Transactions
Conflict Serializability Definition 8.4 (Conflict Serializability): A history for a set of n transactions is conflict serializable if the equivalence of to a serial history can be proven using the commutativity rules alone. Let CSRIDM denote the class of all conflict serializable histories (for ). Definition 8.5 (Conflict Graph): Let T be a set of IDM transactions and a history for The conflict graph of s is defined by: is in if for transactions and in , , there is an update in and an update in s.t And is not equivalent to (i.e., does not hold). Theorem 8.2: Let s be a history for a set T of transactions. Then s is in CSRIDM iff G(s) is acyclic. Concurrency Control on Relational Databases
14
2. Relational Update Transactions
Example 8.6 Consider s = m2(1;2) m1(2;3) m2(3;2) G(s) is cyclic, so s is not in CSRIDM On the other hand, s m1(2;3) m2(1;2) m2(3;2) t1 t2 s is in FSRIDM CSRIDM ⊂ FSRIDM t1 t2 m1(2;3) m2(3;2) m2(1;2) m1(2;3) s = m2(1;2) m1(2;3) m2(3;2) = m(1;2) m(3;2) t1 t2 = m1(2;3) m2(1;2) m2(3;2) = m(2;3)m(3;2) m(1;2) = m(3;2) m(1;2) Consequence: CSRIDM is a strict subset of FSRIDM Concurrency Control on Relational Databases
15
2. Relational Update Transactions
Extended Conflict Serializability Conflict serializability : only take local conflicts into account Final state serializability : look at entire context at once Extended conflicts serializability : between single updates u from one transaction and prefixes of other transactions occurring in a given history prior to u Definition 8.6 (Extended Conflict Graph / Serializability): Let be a history for a set of transactions. (1) The extended conflict graph of is defined by: is in if there is an update in s.t and does not commute with the projection of onto . (2) is extended conflict serializable if is acyclic. Let ECSRIDM denote the class of all extended conflict-serializable histories. Concurrency Control on Relational Databases
16
2. Relational Update Transactions
Example 8.7 t1 t2 m2(1;2) m1(2;3) m1(2;3) m2(3;2) ☞ Example 8.6 s ∈ CSRIDM s ∈ FSRIDM G(s) is cyclic, but s ∈ ECSRIDM Theorem 8.3: CSRIDM ⊂ ECSRIDM ⊂ FSRIDM Concurrency Control on Relational Databases
17
3. Exploiting Transaction Program Knowledge
Transaction Chopping Short transactions need less locks Short transactions cause potentially less lock contention Long transactions can be broken into smaller pieces 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 is a decomposition of into pieces s.t. every step of is contained in exactly one piece and the step order is preserved. Definition 8.10 (Correct Chopping): A chopping of is correct if every execution of the transaction pieces is conflict-equivalent to a serial history of 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. Concurrency Control on Relational Databases
18
3. Exploiting Transaction Program Knowledge
Short Transactions Are Good Concurrency Control on Relational Databases
19
3. Exploiting Transaction Program Knowledge
Chopping Graph Definition 8.9 (Chopping Graph): For a chopping of transaction set the chopping graph is an undirected graph s.t. • the nodes of are the transaction pieces • for two pieces , from different transactions contains a edge between and if and contain conflicting operations • for two pieces , from the same transaction contains an 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 edge and at least one edge. Concurrency Control on Relational Databases
20
3. Exploiting Transaction Program Knowledge
Chopping Graph Concurrency Control on Relational Databases
21
3. Exploiting Transaction Program Knowledge
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 Concurrency Control on Relational Databases
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.