Open In App

Multiversion Timestamp Ordering

Improve
Improve
Like Article
Like
Save
Share
Report

In the Multiversion timestamp ordering technique, for each transaction in the system, a unique timestamp is assigned before the start of the execution of the transaction. The timestamp of a transaction T  is denoted by TS(T).  For each data item X a sequence of versions <X1, X2, X3,……XK> is associated.

For each version Xi of a data item(X), the system maintains the following three fields:

  • The value of the version.
  • Read_TS (Xi): The read timestamp of Xi is the largest timestamp of any transaction that successfully reads version Xi.
  • Write_TS(Xi): The write timestamp of Xi is the largest timestamp of any transaction that successfully writes version Xi.

To ensure serializability the following two rules are used:

Suppose a transaction T issues a read request and a written request for a data item X. Let Xi be the version having the largest Write_TS(Xi) of all the versions of X which is also less than or equal to TS(T).

  • Rule1: Let us suppose the transaction T issues a Read(X) request, If Read_TS(Xi)<TS(T) then the system returns the value of Xi to the transaction T  and update the value of Read_TS(Xi) to TS(T)
  • Rule 2:  Let us suppose the transaction T issues a Write(X) request TS(T) < Read_TS(X), then the system aborts transaction T. On the other hand, if TS(T) = Write_TS(X), the system overwrites the contents of X; if TS(T)>Write_TS(X) it creates a new version of X.

Flowchart for Multi version Timestamp Ordering

Example:

Consider the following schedule

Schedule with Transactions T1 and T2

Let the timestamps of Transaction T1 and T2  be 5 and 10 respectively. These transactions perform read and write operations on a data item X.

  • Assume initially the state of data item X is X0 and Read_TS(X0)=Write_TS(X0)=0
  • T1 performs Read(X), As Read_TS(X0)<TS(T1) so T1 will read the value of X0 and set Read_TS(X0)=TS(T1)=5,
  • T1 performs Write(X), As Write_TS(X0)<TS(T1) this creates new version of X i.e. X1 and sets Read_TS(X1)=Write_TS(X1)=TS(T1)=5.
  • T2 performs Read(X), As  Read_TS(X1)<TS(T2) so T2 will read the value of X1 and set Read_TS(X1)=TS(T2)=10.
  • T2 performs Write(X),As Write_TS(X1)<TS(T2) this creates new version of X i.e. X2 and sets Read_TS(X2)=Write_TS(X2)=TS(T2)=10.
  • T1 performs Read(X), In normal timestamp ordering, this would abort T1 (and subsequently T2) because T2 had already overwritten X. Since we have kept previous versions, we read X1 instead of X2 and the read is successful.
  • T1 performs Write(X), As TS(T1)<Read_TS(X1) (i.e.T2 has already read a version of X that T1 had yet to produce) The system aborts T1.
  • Since T2 had read X1 when T1 aborted it cascaded into T2 and T2 aborted.

Advantages:

  • The read requests by the transaction are never failed and are never made to wait.
  • It finds its application in database systems where read requests are more frequent than write requests.

Disadvantages:

  • The reading of a data item requires the updating of the Read timestamp field, resulting in two potential disk accesses, rather than one.
  • The conflicts between transactions are resolved through rollbacks, rather than through waits. This alternative may be expensive.
  • Multiversion timestamp-ordering scheme does not ensure recoverability and cascadelessness.

Last Updated : 19 Mar, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads