Multi Version Two-Phase Locking Protocol
Multi Version Two-Phase Locking Protocol
R(Q) Q0 W(Q) wait W(Q) Q1 commit Wait over W(Q) executes R(Q) commit W(Q)
7 8 9
1) ts-counter = 0. Ti successfully reads the value of Q in the local variable (buffer) from the DB. Let us call it version Q0 (value is say 10). TS(Q0) = ts-counter = 0 2) Ti puts an exclusive lock and successfully writes the value of Q creating a new version Q1. Content of Q1 = 15 (say) TS(Q1) = 3) Tj successfully reads the value of Q0. It cannot read Q1 because TS(Q1) is which is greater than its own timestamp. 4) Tj cannot write the value of Q as there is an exclusive lock on it. It therefore goes in the wait state. 5) Ti successfully writes (overwrites) the value of Q1. (This is because Q1 was created by Ti itself) 6) (a) Transaction ends, locks are released.
Ms. Anjali Ganesh Jivani
TS(Q1) = ts-counter + 1 = 0 + 1 = 1 ts-counter = ts-counter + 1 = 1 (b) Since locks are released, Tj wait state is over and its write operation executes. (same as 2 executes). Q2 is created with, Content of Q2 = 20 (say) TS(Q2) = 7) Tk successfully reads the value of Q1. It cannot read Q2 because TS(Q2) is which is greater than its own timestamp. 8) Transaction ends, locks are released. TS(Q2) = ts-counter + 1 = 2 ts-counter = ts-counter + 1 = 2 9) Tk puts an exclusive lock and successfully writes the value of Q creating a new version Q3. Content of Q3 = 35 (say) TS(Q3) = Versions are deleted as per the method of multiversion timestamp based protocol.
Advantages: A read request never fails Ensures recoverability and cascadelessness Disadvantages: Deadlocks can occur because transactions go in the wait state
____________________