/    /  DBMS- Timestamp-Based  Protocol

Timestamp-Based  Protocol

  

Suppose a transaction ‘Ti’ entered into the system.

 

The time it enters into the system, a unique fixed timestamp will be generated using the system clock, denoted by TS(Ti).

 

R-TS(Q): denotes the largest time stamp of any transaction that executed read(Q) successfully.

W-TS(Q): denotes the largest time stamp of any transaction that executed write(Q) successfully.

 

Timestamp-Ordering  Protocol :

This protocol ensures that any conflicting read and write operations are executed in timestamp order.

(a) Suppose that transaction Ti issues read(Q) :

i) If TS(Ti) < W-TS(Q),  then Ti needs to read a value of Q that was already overwritten. Hence, the ‘read’ operation is rejected and Ti is rolled back.

 

ii)If TS(Ti)  ≥  W-TS(Q), then the read operation is executed. And R-TS(Q) is set to a maximum of R-TS(Q)  and TS(Ti).

 

(b) Suppose that transaction Ti issues write(Q) :

i)If TS(Ti) < R-TS(Q),  then the value of Q that Ti is producing was needed previously, and the system assumed that that value would never be produced. Hence, the system rejects the ‘write’ operation and rolls Ti back.

 

ii) If TS(Ti)  <  W-TS(Q),  then Ti is attempting to write an obsolete value of Q. Hence, the system rejects this ‘write’ operation and rolls Ti back.

 

iii) Otherwise, the system executes the ‘write’ operation and sets W-TS(Q) to TS(Ti).

 

Reference Link

Timestamp-Based  Protocol