Timestamp-Based Concurrency Control in DBMS
Time-Stamp Transaction Protocol is a concurrency control technique in DBMS that uses timestamps
to order transactions and ensure serializability.
Key Concepts:
1. Timestamp (TS):
- Each transaction T is given a unique timestamp TS(T).
- Older transactions have smaller timestamps.
2. Read_TS(X):
- Highest timestamp of any transaction that successfully read X.
3. Write_TS(X):
- Highest timestamp of any transaction that successfully wrote to X.
Rules:
1. Read(X) by T:
- If TS(T) < Write_TS(X): Abort T.
- Else: Allow read, update Read_TS(X).
2. Write(X) by T:
- If TS(T) < Read_TS(X) or TS(T) < Write_TS(X): Abort T.
- Else: Allow write, update Write_TS(X).
Abort Policy:
- On abort, transaction is rolled back and restarted with a new timestamp.
Example:
- TS(T1) = 5, TS(T2) = 10
- T2 writes to X: Write_TS(X) = 10
- T1 tries to read X: TS(T1) < Write_TS(X) => T1 is aborted.
Pros:
- Simple implementation
- Avoids deadlocks
- Ensures serializability
Cons:
- Can cause many aborts under high contention