Timestamp ordering is a unique value given to every transaction whenever it comes into the system to execute.
There are two types of timestamp values
- Read timestamp: It is the value of the last transaction which successfully performed the read operation.
- Write timestamp: It is the value of the last transaction which successfully performed the read operation.
The timestamp value of the transaction that comes later in the system is always greater than the value of the system that comes early in the system. Let a transaction timestamp Ti which newly comes into the system, and then another transaction Tj comes after T1. Then timestamp of Tj is always greater than the timestamp of Tj i.e. TS(Tj)>TS(Ti).
There are two basic algorithms to ensure that the timestamp value is not violated when more than one transaction is executing into the system.
1). Whenever the transaction T issues the Read operation on data (let’s say X) from the database, then
a). If Read_Timestamp(X) > Timestamp(T) then abort T and rollback the operation.
b). Else execute Read(X) operation and set
Read_Timestamp(X) = max{ Read_Timestamp(A), Transtamp(T)}
2). Whenever the transaction T issues the Write operation on data (let’s say X) from the database, then
a). If Read_Timestamp(X) > Timestamp(T) then abort T and rollback.
b). If write_Timestamp(X) > Timestamp(T) then abort T and rollback.
c). Else execute write(X) operation and set
Write_timestamp(X) = Timestamp(T)