100% found this document useful (9 votes)
6K views

Multi Version Two-Phase Locking Protocol

The Multiversion Two-Phase Locking Protocol combines multiversion timestamp ordering with two-phase locking. It allows read transactions to access prior committed versions of data while write transactions acquire exclusive locks. Each data item has a sequence of versions with timestamps based on a counter. Read transactions access the highest version with a timestamp lower than their own, while write transactions acquire an exclusive lock and set the version timestamp to infinity. This protocol ensures read transactions never fail and the database remains consistent and recoverable, though deadlocks can still occur when transactions wait for locks.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (9 votes)
6K views

Multi Version Two-Phase Locking Protocol

The Multiversion Two-Phase Locking Protocol combines multiversion timestamp ordering with two-phase locking. It allows read transactions to access prior committed versions of data while write transactions acquire exclusive locks. Each data item has a sequence of versions with timestamps based on a counter. Read transactions access the highest version with a timestamp lower than their own, while write transactions acquire an exclusive lock and set the version timestamp to infinity. This protocol ensures read transactions never fail and the database remains consistent and recoverable, though deadlocks can still occur when transactions wait for locks.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Consistency & Concurrency

Multiversion Two-Phase Locking Protocol

Multiversion Two-Phase Locking Protocol:


Combination of multiversion timestamp based protocol and two-phase locking protocol. Update transactions (DMLs) perform rigorous two-phase locking Each data item Q has a sequence of versions <Q1, Q2, , Qn>. Each version of a data item has a single timestamp. Timestamp is based on a counter: ts-counter, which is incremented after every commit. Reading a data item is similar to the multiversion timestamp ordering protocol. Writing (updating) a data time will first put an exclusive lock on that item and will set the timestamp of that version to (infinity) which is a value greater than any possible timestamp. Every transaction will see only committed data of other transactions which committed before it and uncommitted values of its own. Assume the first read of a data item Q from the database to be the initial version Q0. The ts-counter = 0. Sr. No. 1 2 3 4 5 6a 6b Ti R(Q) Q0 W(Q) Q1 Tj Tk

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

Consistency & Concurrency

Multiversion Two-Phase Locking Protocol

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

____________________

Ms. Anjali Ganesh Jivani

You might also like