87% found this document useful (15 votes)
7K views

Multi Version Timestamp Ordering Protocol

The multiversion timestamp ordering protocol maintains multiple versions of each data item. Each version contains the data, a write timestamp (W-TS), and a read timestamp (R-TS). When a transaction reads or writes a data item, it creates a new version with timestamps indicating the transaction that performed the operation. Older versions may be removed once all active transactions have timestamps higher than the writing transaction of the oldest version. This allows reads to always succeed by accessing the newest version with a timestamp before the transaction's, but requires two disk accesses per read and uses rollbacks instead of waits to resolve conflicts.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
87% found this document useful (15 votes)
7K views

Multi Version Timestamp Ordering Protocol

The multiversion timestamp ordering protocol maintains multiple versions of each data item. Each version contains the data, a write timestamp (W-TS), and a read timestamp (R-TS). When a transaction reads or writes a data item, it creates a new version with timestamps indicating the transaction that performed the operation. Older versions may be removed once all active transactions have timestamps higher than the writing transaction of the oldest version. This allows reads to always succeed by accessing the newest version with a timestamp before the transaction's, but requires two disk accesses per read and uses rollbacks instead of waits to resolve conflicts.
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 Timestamp Ordering Protocol

Multiversion Timestamp Ordering Protocol:


Each data item Q has a sequence of versions <Q1, Q2, , Qn>. Each version Qk has three fields: Content of Qk W- TS(Qk) TS of transaction that created Qk R-TS(Qk) largest TS of transaction that read Qk Every time a version changes the W-TS and the R-TS is set to the transaction that made the change. Assume the first read of a data item Q from the database to be the initial version Q0.

Sr. No. 1 2 3 4 5 6 7 8 9

Ti R(Q) W(Q)

Tj

Tk

R(Q) W(Q) R(Q) W(Q) W(Q) R(Q) W(Q)

1) 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). 2) Ti successfully writes the value of Q creating a new version Q1. Content of Q1 = 15 (say) R-TS(Q1) = TS(Ti) W-TS(Q1) = TS(Ti) 3) Tj successfully reads the value of Q1 created by Ti. R-TS(Q1) = TS(Tj) 4) Tj successfully writes the value of Q creating a new version Q2. Content of Q2 = 20 (say) R-TS(Q2) = TS(Tj) W-TS(Q2) = TS(Tj) 5) Ti successfully reads the value of Q1 (and not Q2) because the timestamp of Q1 is equal to its own timestamp. (it cannot read a version which has a TS greater than its own). According to the Timestamp based protocol this request would have generated a rollback of Ti as W(Q) of Tj has already taken place. 6) The write requested is rejected because as per timestamp based protocol R(Q) and W(Q) of Tj (younger transaction) has already taken place. Ti therefore rollbacks. 7) Tj successfully writes (overwites) the value of Q2. (This is because Q2 was created by Tj)

Ms. Anjali Ganesh Jivani

Consistency & Concurrency

Multiversion Timestamp Ordering Protocol

Content of Q2 = 25 (say) R-TS(Q2) = TS(Tj) W-TS(Q2) = TS(Tj) The read and the write timestamp remain the same. 8) Tk successfully reads the value of Q2. R-TS(Q2) = TS(Tk) 9) Ti successfully writes the value of Q creating a new version Q3. Content of Q3 = 30 (say) R-TS(Q3) = TS(Tk) W-TS(Q3) = TS(Tk) Since every transaction keeps on creating a new version, there has to be a way in which older versions can be removed from the buffer. Assume that there are five transactions active in the system Ti, Tj, Tk, Tl, Tm. Each one is accessing the same data items. (TS(Ti) < TS(Tj) < ). Suppose Ti and Tj have been completed and are no more active in the system. Ti had created Q1 and Tj had created Q2. If Q needs to be read then Q2 is the latest version whose W-TS would be less than the timestamp of the oldest active transaction (Tk). This means Q1 will never be read by any transaction and hence can be removed from the system. Ti R(Q) W(Q) Q1 Commit Tj Tk Tl Tm

R(Q) Q1 W(Q) Q2 Commit

R(Q) Q2 W(Q) Q3

R(Q) Q2 R(Q) Q3 W(Q) Q4 R(Q) Q4

Tk, Tl and Tm will never read Q1 and so Q1 can be removed. Advantages: A read request never fails Deadlocks will not occur because of rollbacks Disadvantages: Reading of data requires updating of R-TS (two disk accesses) Does not ensure recoverability and cascadelessness Uses rollbacks to resolve conflicts instead of waits _____________________

Ms. Anjali Ganesh Jivani

You might also like