420 likes | 576 Views
. The Serializability of Concurrent Database Updates. CHRISTOS H. PAPADIMITRIOU (Journal of the ACM, Volume 26, 1979) Presented by: Yuri Meshman. Contents. Transactions History (Preliminary definitions) SR is NPC (stencil of proof) Polygraph SR Subsets in P DSR The Class Q
E N D
The Serializability of Concurrent Database Updates CHRISTOS H. PAPADIMITRIOU (Journal of the ACM, Volume 26, 1979) Presented by: Yuri Meshman For any comments or updates contact: syurim@gmail.com
Contents • Transactions History (Preliminary definitions) • SR is NPC (stencil of proof) • Polygraph • SR Subsets in P • DSR • The Class Q • Two-Phase locking and P3 • Topography of SR, S, Q, SSR, DSR, P3 and 2PL • Restrictions on Read Write Set (when SR is in P) • Schedulers of Histories • Discussion – extension to transactions with multiple steps – not going through
Contents • Transactions History (Preliminary definitions) • SR is NPC (stencil of proof) • Polygraph • SR Subsets in P • DSR • The Class Q • Two-Phase locking and P3 • Topography of SR, S, Q, SSR, DSR, P3 and 2PL • Restrictions on Read Write Set (when SR is in P) • Schedulers of Histories • Discussion – extension to transactions with multiple steps – not going through
Transactions HistoryTransaction-Bank Example Central Bank Registry Lucy Ricky A B C 500 500 500 Read (A, t) t = t - 100 500 400 500 Write (A, t) Read (A, s) s = s - 100 Write (A, s) 300 500 500 Read (B, t) t = t + 100 300 600 500 Write (B, t) Read (C, s) s = s + 100 Write (C, s) 300 600 600 300 + 600 + 600 = 1500
Transactions HistoryTransaction-Bank Example Central Bank Registry Lucy Ricky A B C 500 500 500 Read (A, t) t = t - 100 Read (A, s) s = s - 100 500 Write (A, s) 400 500 400 500 500 Write (A, t) Read (B, t) t = t + 100 400 600 500 Write (B, t) Read (C, s) s = s + 100 Write (C, s) 400 600 600 400 + 600 + 600 = 1600
Transactions HistoryFrom Databases to Programs start F F J F J J Halt
Transactions HistoryFrom Databases to Programs start F • equivalent histories if and only if • their program schemata are equivalent. • For:- Any set of domains for the variables • Any set of initial values • Any interpretation for the functions • The values of the variables are identical after the execution in both histories. F J F J J Halt
Transactions HistoryHistories Equivalence Proposition 1. Two histories and are equivalentiff they have the same set of live transactions, and a live reads from in iff reads from in .
Transactions HistoryHistories Equivalence Proposition 1. Two histories and are equivalentiff they have the same set of live transactions, and a live reads from in iff reads from in . Corollary. Equivalence of histories can be decided in time.
Transactions HistorySerializability A history is serial if for all . immediatly precedes . A history is serializable if there is a serial history such that Notation:
Contents • Transactions History • SR is NPC (stencil of proof) • Polygraph • SR Subsets in P • DSR • The Class Q • Two-Phase locking and P3 • Topography of SR, S, Q, SSR, DSR, P3 and 2PL • Restrictions on Read Write Set (when SR is in P) • Schedulers of Histories • Discussion – extension to transactions with multiple steps – not going through
SR is NPCPolygraph - Introduction Definition 1. A polygraph is a digraph together with a set of bipaths, pairs of arcs – not necessarily in A – of the form such that . Alternatively, a family Dof digraphs. A digraph is in D iff , and for bipath, contains one of . v
SR is NPCPolygraph- Introduction Definition 1. A polygraph is a digraph together with a set of bipaths, pairs of arcs – not necessarily in A – of the form such that . Alternatively, a family Dof digraphs. A digraph is in D iff , and for bipath, contains one of . v
SR is NPCPolygraph– Acyclicity Definition 2. A polygraph is acyclic if there is an a cyclic digraph is in D. v
SR is NPCTransactions Polygraph is live transactions of Given . If reads a variable from : Furthermore if is writing to :
SR is NPCTransactions Polygraph Lemma 1. Two histories are equivalent iff are identical Lemma 2. is serializable iff is acyclic
SR is NPCThe proof stencil Theorem 1. Testing if h is serializable is NP-complete, even if h has no dead transactions. Preliminary: 3SAT is NPC Lemma 3. 3SAT is NPC when formulas are non circular (no repeating variables) Theorem 1 proof: reduction from 3SAT to polygraph acyclicity
SR is NPCConstruction of =x or
SR is NPCConstruction of =x or
Contents • Transactions History • SR is NPC (stencil of proof) • Polygraph • SR Subsets in P • DSR • The Class Q • Two-Phase locking and P3 • Topography of SR, S, Q, SSR, DSR, P3 and 2PL • Restrictions on Read Write Set (when SR is in P) • Schedulers of Histories • Discussion – extension to transactions with multiple steps – not going through
SR Subsets in PDSR-conflict serializability Definition 3. Let , . We write if , for some , and: • for some or • , or Letbe the transitive reflexive closure of . Since is symmetric is an equivalence relation
SR Subsets in PDSR-conflict serializability Proposition 2. If then is a proper subset of h is D-serializable(DSR) iff there exists a serial history h such that
SR Subsets in PDSR-conflict serializability We can associate with a history h a digraph D(h) as follows: is an arc if: • and , or • and or • and Theorem 2. A history h is DSR iff D(h) is acyclic.
SR Subsets in PDSR-conflict serializability Corollary 2. A history is DSR iff we can find real numbers with the following properties • and , then • and then • and Corollary 1. Checking whether a history is DSR can be done in
SR Subsets in PThe class Q Definition 4. A history h is in Q if there exist non integer, distinct real numbers such that: • and , then • and
SR Subsets in PThe class Q Theorem 3. If h is in Q, then h is DSR. We can associate with a history h a digraph D’(h) a super graph as follows: is an arc if: • and or • and
SR Subsets in PTwo Phase locking and P3 Definition 5. h is two phase locked (iff there exist distinct non-integer real numbers (the lockpoints) s.t: • and , then • and
SR Subsets in PTwo Phase locking and P3 The inclusion is proper:
SR Subsets in PTwo Phase locking and P3 Definition 6. Let G(h) be an undirected graph corresponding to D(h). A cycle - s.t. is an edge - is bad if and
SR Subsets in PTwo Phase locking and P3 Definition 6.(continued) is a guardian of if is part of a bad cycle in G(h). h obeys the P3 protocol () if when is a guardian of we do not have
SR Subsets in PSSR Definition 7. is Serializable in the Strict Sense h if there is a serial history such that and , implies .
Contents • Transactions History • SR is NPC (stencil of proof) • Polygraph • SR Subsets in P • DSR • The Class Q • Two-Phase locking and P3 • Topography of SR, S, Q, SSR, DSR, P3 and 2PL • Restrictions on Read Write Set (when SR is in P) • Schedulers of Histories • Discussion – extension to transactions with multiple steps – not going through
Restrictions on Read Write Set (SR is in P) Theorem 8. If for w for then is serializable iff is DSR.
Contents • Transactions History • SR is NPC (stencil of proof) • Polygraph • SR Subsets in P • DSR • The Class Q • Two-Phase locking and P3 • Topography of SR, S, Q, SSR, DSR, P3 and 2PL • Restrictions on Read Write Set (when SR is in P) • Schedulers of Histories • Discussion – extension to transactions with multiple steps – not going through
Schedulers of Histories 2PL and P3 correspond to simple schedulers. A trivial scheduler will generate only serial histories. Scheduler task becomes interesting and important when he must transform the arriving schedule to a non equivalent output which is closest to the input. Definition 8. A schedule, for (histories), is such that
Schedulers of Histories Assumptions: • works online (receiving transactions) • Optimism – doesn’t change order of transactions seen so far, if can be extended to a serializable history. efficient if computable in polynomial time. Q: Which classes of histories have efficient schedulers. Efficient scheduler if the input class is in P? No
Schedulers of Histories Should be computed efficiently by proposed scheduler. Check for if the output starts with - to check SR efficiently. Efficient scheduler if the input class is in P? No
Schedulers of Histories • Corollary 1. Unless P=NP, SR has no efficient scheduler. • Corollary 2. S, 2PL, P3, Q, DSR have efficient schedulers.