The Serializability of Concurrent Database Updates

42
1 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: [email protected]

description

. 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 - PowerPoint PPT Presentation

Transcript of The Serializability of Concurrent Database Updates

Page 1: The Serializability of Concurrent Database Updates

1

The Serializability of Concurrent

Database UpdatesCHRISTOS H. PAPADIMITRIOU

(Journal of the ACM, Volume 26, 1979)

Presented by: Yuri Meshman

For any comments or updates contact: [email protected]

Page 2: The Serializability of Concurrent Database Updates

2

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

Page 3: The Serializability of Concurrent Database Updates

3

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

Page 4: The Serializability of Concurrent Database Updates

4

Transactions History

Transaction-Bank Example

Read (A, t)t = t - 100Write (A, t)

Read (B, t)t = t + 100Write (B, t)

Read (A, s)s = s - 100Write (A, s)

Read (C, s)s = s + 100Write (C, s)

Lucy Ricky A B C

300 600600

500 500500

300 500500

300 500600

300 + 600 + 600 = 1500

400 500500

Central Bank Registry

Page 5: The Serializability of Concurrent Database Updates

5

Transactions History

Transaction-Bank Example

Read (A, t)t = t - 100

Write (A, t) Read (B, t)t = t + 100Write (B, t)

Read (A, s)s = s - 100Write (A, s)

Read (C, s)s = s + 100Write (C, s)

Lucy Ricky A B C

400 600600

500 500500

400 500500400 500500

400 500600

400 + 600 + 600 = 1600

Central Bank Registry

Page 6: The Serializability of Concurrent Database Updates

6

Transactions History

Definition

, , ,h n V S

1 2 1 3 2 3, ,h R x R W x y R x W x y W y

1 1 2

positive integer, , , , ,

permutation of - a finite set of variables

- a funcion : 2

n n n

n

Vn

nR W R R W

V

S

1 3 2 1 2, , , ,...S R S R x S R S W S W x y

,i i iT R W

Page 7: The Serializability of Concurrent Database Updates

7

Transactions HistoryFrom Databases to

Programs 1 2 1 3 2 3, ,h R x R W x y R x W x y W y𝑡11← 𝑥

start

F

F

Halt

J

𝑡 31←𝑥F

J

J

y←t32

𝑡 32←f 31 (t 31 )

Page 8: The Serializability of Concurrent Database Updates

8

Transactions HistoryFrom Databases to

Programs 1 2 1 3 2 3, ,h R x R W x y R x W x y W y𝑡11← 𝑥

start

F

F

Halt

J

𝑡 31←𝑥F

J

J

y←t32

𝑡 32←f 31 (t 31 )

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.

Page 9: The Serializability of Concurrent Database Updates

9

Transactions History

Histories EquivalenceProposition 1. Two histories and are equivalentiff they have the same set of live transactions, and a live reads from in iff reads from in .

1 2 1 3 2 3, ,h R x R W x y R x W x y W y

1 1 1 2 1 3 2 3 2 2, , , ,n n n nh R W x y R x RW x y R x W x y W y R x y W

Page 10: The Serializability of Concurrent Database Updates

11

Transactions History

Histories EquivalenceProposition 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.

Page 11: The Serializability of Concurrent Database Updates

12

Transactions History

SerializabilityA history is serial if for all . immediatly precedes .

A history is serializable if there is a serial history such that

Notation:

Page 12: The Serializability of Concurrent Database Updates

13

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

Contents

Page 13: The Serializability of Concurrent Database Updates

14

SR is NPC

Polygraph - IntroductionDefinition 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 D of digraphs. A digraph is in D iff , and for bipath , contains one of .

v𝑢𝑤

Page 14: The Serializability of Concurrent Database Updates

15

SR is NPC

Polygraph- IntroductionDefinition 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 D of digraphs. A digraph is in D iff , and for bipath , contains one of .

v𝑢𝑤

Page 15: The Serializability of Concurrent Database Updates

16

SR is NPC

Polygraph – Acyclicity Definition 2. A polygraph is acyclic if there is an a cyclic digraph is in D .

v𝑢𝑤

Page 16: The Serializability of Concurrent Database Updates

17

SR is NPC

Transactions PolygraphGiven .

If reads a variable from : Furthermore if is writing to :

𝑇 1 𝑇 2

𝑇 3𝑇 4

𝑇 5 𝑇 6

𝑇 𝑛+ 1

𝑇 𝑛+ 2

is live transactions of

𝑇 7

𝑊 4[𝑦 , 𝑧 ]𝑊 2 [𝑥 ]𝑅1 [ 𝑥 , 𝑦 ]𝑅3 [ 𝑦 ]𝑊 7 [ 𝑦 ]𝑊 5 [ 𝑧 , 𝑠 ]𝑅6 [ 𝑠 ]𝑊 6 [𝑧 ]…

Page 17: The Serializability of Concurrent Database Updates

18

SR is NPC

Transactions PolygraphLemma 1. Two histories are equivalent iff are identical

Lemma 2. is serializable iff is acyclic

𝑇 1 𝑇 2

𝑇 3𝑇 4

𝑇 5 𝑇 6

𝑇 𝑛+ 1

𝑇 𝑛+ 2

𝑇 7

𝑊 4[𝑦 , 𝑧 ]𝑊 2 [𝑥 ]𝑅1 [ 𝑥 , 𝑦 ]𝑅3 [ 𝑦 ]𝑊 7 [ 𝑦 ]𝑊 5 [ 𝑧 , 𝑠 ]𝑅6 [ 𝑠 ]𝑊 6 [𝑧 ]…

Page 18: The Serializability of Concurrent Database Updates

19

SR is NPC

The proof stencilTheorem 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

Page 19: The Serializability of Concurrent Database Updates

20

SR is NPC

Construction of =x or

Page 20: The Serializability of Concurrent Database Updates

21

SR is NPC

Construction of =x or

𝑎𝑠

Page 21: The Serializability of Concurrent Database Updates

22

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

Contents

Page 22: The Serializability of Concurrent Database Updates

23

SR Subsets in P

DSR-conflict serializability Definition 3. Let , . We write if , for some , and:a) for some orb) , or

𝑅1 [ 𝑥 ]𝑅2 [ 𝑥 ]𝑾 𝟏 [𝒙 ]𝑾 𝟐 [𝒚 ] 𝑹𝟏 [𝒚 ]𝑹𝟐 [𝒙 ]𝑊 2 [ 𝑥 ]𝑊 1 [ 𝑦 ]𝑅2 [𝑥 ]𝑹𝟏 [𝒚 ]𝑾 𝟐 [𝒙 ]𝑊 1 [ 𝑦 ]𝑅2 [ 𝑥 ]𝑊 2 [ 𝑥 ]𝑅1 [ 𝑦 ]𝑊 1 [ 𝑦 ]

Let be the transitive reflexive closure of . Since is symmetric is an equivalence relation

Page 23: The Serializability of Concurrent Database Updates

24

SR Subsets in P

DSR-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

Page 24: The Serializability of Concurrent Database Updates

25

SR Subsets in P

DSR-conflict serializability We can associate with a history h a digraph D(h) as follows: is an arc if:a) and , orb) and orc) and

Theorem 2. A history h is DSR iff D(h) is acyclic.

Page 25: The Serializability of Concurrent Database Updates

26

SR Subsets in P

DSR-conflict serializability

Corollary 2. A history is DSR iff we can find real numbers with the following propertiesa) and , then b) and thenc) and

Corollary 1. Checking whether a history is DSR can be done in

Page 26: The Serializability of Concurrent Database Updates

27

SR Subsets in P

The class QDefinition 4 . A history h is in Q if there exist non integer, distinct real numbers such that:a) b) and , then c) and

Page 27: The Serializability of Concurrent Database Updates

28

SR Subsets in P

The class QTheorem 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:a) b) and orc) and

h=𝑅1𝑅2𝑅3 [ 𝑥 ]𝑊 1 [ 𝑥 ]𝑊 2 [𝑦 ,𝑧 ]𝑊 3 [𝑦 ]

Page 28: The Serializability of Concurrent Database Updates

29

SR Subsets in P

Two Phase locking and P3Definition 5. h is two phase locked ( iff there exist distinct non-integer real numbers (the lockpoints) s.t:a) b) and , then c) and

Page 29: The Serializability of Concurrent Database Updates

30

SR Subsets in P

Two Phase locking and P3

The inclusion is proper:

Page 30: The Serializability of Concurrent Database Updates

31

SR Subsets in P

Two Phase locking and P3Definition 6. Let G(h) be an undirected graph corresponding to D(h). A cycle - s.t. is an edge - is bad if and

Page 31: The Serializability of Concurrent Database Updates

32

SR Subsets in P

Two Phase locking and P3Definition 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

Page 32: The Serializability of Concurrent Database Updates

33

SR Subsets in P

SSRDefinition 7. is Serializable in the Strict Sense h if there is a serial history such that and , implies .

𝑄⊂𝑆𝑆𝑅

Page 33: The Serializability of Concurrent Database Updates

34

SR Subsets in P

Topography

Page 34: The Serializability of Concurrent Database Updates

35

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

Contents

Page 35: The Serializability of Concurrent Database Updates

36

Restrictions on Read Write Set (SR is in P)

Theorem 8. If for w for then is serializable iff is DSR.

Page 36: The Serializability of Concurrent Database Updates

37

Restrictions on Read Write Set (SR is in P)

Page 37: The Serializability of Concurrent Database Updates

38

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

Contents

Page 38: The Serializability of Concurrent Database Updates

39

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

Page 39: The Serializability of Concurrent Database Updates

40

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. NoEfficient scheduler if the input class is

in P?

Page 40: The Serializability of Concurrent Database Updates

41

Schedulers of

Histories Should be computed efficiently by proposed scheduler.

Check for if the output starts with - to check SR efficiently.

NoEfficient scheduler if the input class is in P?

Page 41: The Serializability of Concurrent Database Updates

42

Schedulers of

Histories Corollary 1. Unless P=NP, SR has no efficient

scheduler.

Corollary 2. S, 2PL, P3, Q, DSR have efficient schedulers.

Page 42: The Serializability of Concurrent Database Updates

43

Thank you