What is importance of concurrency control explain with example time stamping protocol?

In the previous chapter, you learned lock based protocol in DBMS to maintain the integrity of database. In this chapter, you will learn Timestamp based ordering protocol.

  • Timestamp ordering protocol maintains the order of transaction based on their timestamps.
  • A timestamp is a unique identifier that is being created by the DBMS when a transaction enters into the system. This timestamp can be based on the system clock or a logical counter maintained in the system.
  • Timestamp helps identifying the older transactions [transactions that are waiting in line to be executed] and gives them higher priority compared to the newer transactions. This make sure that none of the transactions are pending for a longer period of time.
  • This protocol also maintains the timestamps for the last read and last write on a data.
  • For example, let’s say an old transaction T1 timestamp is TS[T1] and a new transaction T2 enters into the system, timestamp assigned to T2 is TS[T2]. Here TS[T1] < TS[T2] so the T1 has the higher priority because its timestamp is less than timestamp of T2. T1 would be given the higher priority than T2. This is how timestamp based protocol maintains the serializability order.

How a Timestamp ordering protocol works?

Let’s see how a timestamp ordering protocol works in a DBMS system. Let’s say there is data item A in the database.

W­_TS[A] is the largest timestamp of a transaction that executed the operation write[A] successfully.
R_TS[A] is the largest timestamp of a transaction that executed the operation read[A] successfully.

  1. Whenever a Transaction Tn issues a Write[A] operation, this protocol checks the following conditions:
    • If R_TS[A] > TS[Tn] or if W_TS[A] > TS[Tn], then abort and rollback the transaction Tn and reject the write [A] operation.
    • If R_TS[A]

Bài Viết Liên Quan

Chủ Đề