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






Durability is the ability of the system to ensure that committed transactions are permanently recorded and cannot be lost or corrupted.
This is achieved by writing the data to a durable storage medium, such as a hard disk or solid-state drive.
The system must ensure that every committed transaction is durable and every aborted or rolled back transaction has no effect.
This can interact with isolation.
While serializability is important, it isn’t enough for full isolation when we take into account durability.
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)
Thus we have a number of goals for scheduling concurrent txns.
We desire that schedules of concurrent txns are:
Locking is one way to provide concurrency control.
Locking involves associating one or more locks with each database element.
We can associate a lock with





We will attempt to use locks to enforce serializability.
However, just having locks isn’t enough to guarantee serializability.
Example: our problematic schedule can still be carried out.



The problem is that T1 released its lock on balance1 “too soon”.
Notice that T1 acquired a lock on balance2 later; this suggests that the transaction was not “done” when it released the lock on balance1.
One way to fix this problem, so as to ensure serializability, is two-phase locking (2PL).
2PL requires that:
In our earlier example, T1 does not follow the 2PL rule.
2PL would prevent this interleaving.











Is the schedule at left:
conflict serializable?