Boston University
Example: r2(A); r3(A); r1(B); w4(A); w2(B); r3(B)
r2(A) … w4(A) means T2 → T4
r3(A) … w4(A) means T3 → T4
r1(B) … w2(B) means T1 → T2
w2(B) … r3(B) means T2 → T3





r1(A) … w2(A) means T1 → T2
r3(A) … w2(A) means T3 → T2
r1(B) … w2(B) means T1 → T2
w2(A) … r4(A) means T2 → T4
w3(C) … w4(C) means T3 → T4
w3(C) … r1(C) means T3 → T1
w4(C) … r1(C) means T4 → T1









r1(A) … w3(A) means T1 → T3
r1(A) … w4(A) means T1 → T4
w3(A) … w4(A) means T3 → T4
w2(B) … r1(B) means T2 → T1
w2(B) … r4(B) means T2 → T4








equivalent serial ordering?
→ equivalent to T2; T1; T3; T4
w1(A) … r2(A) means T1 → T2
w1(A) … r4(A) means T1 → T4
w2(B) … r4(B) means T2 → T4
w4(C) … w3(C) means T4 → T3







A. Yes. It is equivalent to the serial schedule T1;T2;T3;T4
B. Yes. It is equivalent to the serial schedule T1;T2;T4;T3
C. No. The graph includes the cycle T1 → T4 → T2 → T1
D. No. The graph includes the cycle T1 → T2 → T4 → T1
w1(A) … r2(A) means T1 → T2
w1(A) … r4(A) means T1 → T4
w2(B) … r4(B) means T2 → T4
w4(C) … w3(C) means T4 → T3
r3(D) … w1(D) means T3 → T1






While serializability is important, it isn’t enough for full isolation.
Consider the serializable schedule at right.








A. T1 is rolled back sometime after T3 reads A. yes
B. T2 is rolled back sometime after T1 reads B. yes
C. T3 is rolled back sometime after T2 reads C. yes
D. two of the above
E. all three of the above (A, B and C)
Locking is one way to provide concurrency control.
Involves associating one or more locks with each database element.





Just having locks isn’t enough to guarantee serializability.
Example: our problematic schedule can still be carried out.



One way to ensure serializability is two-phase locking (2PL).
2PL requires that all of a txn’s lock actions come before all its unlock actions.
In our earlier example, T1 does not follow the 2PL rule.
2PL would prevent this interleaving.









