Multiversion Timestamp Ordering


Multiversion Timestamp Ordering (MVTO) is a popular concurrency control technique used in database management systems (DBMSs). MVTO allows multiple versions of a data item to coexist at the same time, providing high concurrency and data consistency while preventing conflicts and deadlocks.

In this article, we will discuss the definition and components of MVTO, as well as how it works.

Multiversion Timestamp Ordering (MVTO)

In MVTO, each version of the data item has a unique timestamp associated with it. Transactions that access the data item are assigned timestamps as well.

There are three components of MVTO: timestamps, versions, and ordering −

  • Timestamps are assigned to transactions and data item versions to determine the order of operations.

  • Versions are created when a data item is modified, and each version has a unique timestamp.

  • Ordering ensures that transactions only access the appropriate version of the data item based on their timestamps.

How MVTO works

Read operations

There are two types of read operations. These are read-only and read-write transactions.

  • A read-only transaction can access any version of a data item. He was present at the time of initiation of the transaction.

  • Read-write transactions can only access the latest version of the data item. That version was created before the transaction was committed.

II. Write operation

There are three types of write operations: insertion, deletion, and update.

  • In case of data item insertion. It is given a new timestamp.

  • In case of deletion of a data item. It is marked as deleted but not physically removed from the database.

  • In the case of a data item update. A new version with a new timestamp is created, and the old version is marked as deleted.

Multiversion timestamp ordering technique for serializability

In the Multiversion timestamp ordering technique, unique timestamps are assigned to each transaction and multiple versions are maintained for each data item. The technique ensures serializability by following two rules.

Rule-1

If a transaction T issues a Read(X) request, and Read_TS(Xi) < TS(T), the system returns the value of Xi to the transaction T and updates Read_TS(Xi) to TS(T).

Rule-2

If a transaction T issues a Write(X) request and TS(T) < Read_TS(X), the system aborts transaction T. 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.

Maintained fields for each version of a data item −

  • 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.

Example

Consider the following schedule with Transactions T1 and T2, where T1 has a timestamp of 5 and T2 has a timestamp of 10.

T1

T2

Read(X)

Write(X)

Read(X)

Write(X)

Read(X)

Write(X)

Write(X)

  • Initially, the state of data item X is X0 and Read_TS(X0) = Write_TS(X0) = 0.

  • T1 performs Read(X), reads the value of X0, and sets Read_TS(X0) = TS(T1) = 5.

  • T1 performs Write(X), creates a new version X1 and sets Read_TS(X1) = Write_TS(X1) = TS(T1) = 5.

  • T2 performs Read(X), reads the value of X1, and sets Read_TS(X1) = TS(T2) = 10.

  • T2 performs Write(X), creates a new version X2 and sets Read_TS(X2) = Write_TS(X2) = TS(T2) = 10.

  • T1 performs Read(X), reads X1, and the read is successful.

  • T1 performs Write(X), but since T2 has already read X1, the system aborts T1.

  • The abort of T1 cascades into T2, and T2 also aborts.

Flowchart for Multiversion Timestamp Ordering

Advantages of Disadvantages of MVTO

Here are the advantages and disadvantages of Multiversion Timestamp Ordering (MVTO) in points −

Advantages

  • High concurrency

  • Preventing conflicts and deadlocks

  • Data consistency

  • Support for long-running transactions

Disadvantages

  • Storage overhead

  • Increased computational complexity

  • Limited scalability

Conclusion

In conclusion, Multiversion Timestamp Ordering is a concurrency control technique. It allows for multiple versions of a data item to be stored and used by transactions. Each transaction is assigned a unique timestamp. Each version of a data item, the system maintains the value, read timestamp, and write timestamp.

By allowing multiple versions of a data item to be stored, Multiversion Timestamp Ordering avoids unnecessary aborts of transactions. It reduces contention for the same version of a data item. But, it also requires more storage space and may lead to increased overhead due to the maintenance of multiple versions.

Updated on: 17-May-2023

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements