Timestamp Ordering Protocols in DBMS: Read/Write Rules, Worked Schedules and Exam Traps

Learn a mechanical ledger method for basic timestamp ordering, Thomas write rule and strict timestamp ordering, with checked schedules and comparison tables.

KnowledgeGate Team

Exam prep & CS education

Updated 1 Dec 20266 min read
Timestamp Ordering Protocols in DBMS: Read/Write Rules, Worked Schedules and Exam Traps

Timestamp-ordering questions are often lost because a learner reverses older and newer, checks the wrong timestamp, or updates metadata after rejection. A mechanical method fixes this. Trace schedules mechanically and distinguish basic ordering, the Thomas write rule, and strict ordering.

Timestamp ordering in DBMS: the serial order is chosen first

A transaction receives a unique timestamp when it starts. Suppose TS(T1) = 5, TS(T2) = 10, TS(T3) = 20 and TS(T4) = 25. Smaller means older, so the intended serial order is T1 -> T2 -> T3 -> T4, even if operations arrive differently.

Every item X stores two metadata values:

  • R_TS(X): the largest timestamp among transactions whose reads of X were accepted.

  • W_TS(X): the timestamp of the transaction whose accepted write most recently produced the current version.

These timestamps are not the value of X. If schedules or serialisability need revision first, use Transactions & Concurrency Control in DBMS. Timestamp ordering then fits naturally into the wider GATE CS Exam Preparation path.

Basic timestamp ordering rules: test before changing anything

For read_T(X), abort T if TS(T) < W_TS(X). Otherwise, accept and set R_TS(X) = max(R_TS(X), TS(T)). An older transaction cannot read a newer transaction's value without reversing the serial order.

For write_T(X), check R_TS(X) first. Abort if TS(T) < R_TS(X); otherwise abort if TS(T) < W_TS(X); otherwise write and set W_TS(X) = TS(T).

Operation

Reject when

Action when accepted

Metadata update

read_T(X)

TS(T) < W_TS(X)

Return current X

R_TS(X) = max(R_TS(X), TS(T))

write_T(X)

TS(T) < R_TS(X), then TS(T) < W_TS(X)

Replace X

W_TS(X) = TS(T)

Equality is accepted because the tests use <, not <=. A rejected read, an aborted write, or a Thomas-ignored write changes neither the data nor its timestamps.

Basic timestamp ordering worked schedule

Start with X = 100, R_TS(X) = 0, W_TS(X) = 0, and execute r2(X); w1(X = 110); w3(X = 140); r2(X); r4(X).

Operation

Before (X, R_TS, W_TS)

Comparison

Decision and value

After (X, R_TS, W_TS)

r2(X)

(100, 0, 0)

10 < 0 is false

Accept, return 100

(100, 10, 0)

w1(X = 110)

(100, 10, 0)

5 < 10 is true

Abort T1, no write

(100, 10, 0)

w3(X = 140)

(100, 10, 0)

20 < 10 and 20 < 0 are false

Accept, write 140

(140, 10, 20)

second r2(X)

(140, 10, 20)

10 < 20 is true

Abort T2, no read

(140, 10, 20)

r4(X)

(140, 10, 20)

25 < 20 is false

Accept, return 140

(140, 25, 20)

The final state is X = 140, R_TS(X) = 25, W_TS(X) = 20. T1 and T2 abort. Neither rejection updates metadata.

Five-step timestamp trace ends at X=140, R_TS=25 and W_TS=20 after two accepted reads, one accepted write and two rejections.

Thomas write rule: ignore only a safely obsolete write

Take fresh item Y = 50, R_TS(Y) = 0, W_TS(Y) = 0. T3 has timestamp 20; its w3(Y = 90) passes both tests, so Y = 90 and W_TS(Y) = 20. Now T2, timestamp 10, attempts w2(Y = 70).

The read-timestamp test 10 < 0 is false, but 10 < 20 is true. Basic ordering aborts T2. Thomas instead ignores the obsolete write, keeps T2 active, and leaves Y = 90, R_TS(Y) = 0, W_TS(Y) = 20. In timestamp order, T3 would overwrite T2 before a later observer needed its value.

The relaxation has a firm boundary. If T4 first reads Y, then R_TS(Y) = 25. The later w2(Y = 70) must abort because 10 < 25. Thomas never ignores a violation of R_TS.

Thomas write-rule flowchart compares aborting and ignoring T2's obsolete write, then shows a read-timestamp violation that must abort T2.

Strict timestamp ordering and recoverability

Basic ordering enforces timestamp order without waiting, so it is deadlock-free, but it can expose an uncommitted write. Strict ordering delays a conflicting read or write until the earlier writer commits or aborts, creating a strict, recoverable schedule.

Let Z = 500. T3, timestamp 20, writes Z = 540 but remains uncommitted. T4, timestamp 25, requests r4(Z). Basic checks allow it because 25 >= W_TS(Z) = 20. If T4 commits and T3 later aborts, the schedule is not recoverable because T4 read uncommitted data.

Strict ordering makes r4(Z) wait. If T3 commits, T4 reads 540; if T3 aborts, T4 reads restored value 500. Waiting follows older-to-newer dependencies. Repeated abort and restart can still cause starvation, so deadlock freedom is not starvation freedom.

Solve timestamp ordering schedules with a ledger

Use four steps:

  1. Write every TS(T) and initialise R_TS and W_TS for each item.

  2. Select the read or write rule before considering the desired answer.

  3. Test comparisons in order, then update the ledger only after acceptance.

  4. Track transaction status. Ignore later operations of an aborted transaction unless it restarts with a new timestamp.

Two diagnostic states clarify reads and writes. With TS(Ta) = 8, R_TS(Q) = 12, W_TS(Q) = 5, ra(Q) is accepted because 8 < 5 is false, and R_TS(Q) remains 12. Independently, wa(Q) aborts because 8 < 12.

Now use R_TS(Q) = 3, W_TS(Q) = 11. ra(Q) aborts because 8 < 11. Independently, wa(Q) passes 8 < 3, then basic ordering aborts it because 8 < 11; Thomas ignores that write. Finally, check that no lower-timestamp transaction overwrites a result already observed or written by a higher-timestamp one.

Timestamp ordering exam patterns and traps

Check

Basic TO

Thomas write rule

Strict TO

Old read behind W_TS

Abort

Abort

Abort by timestamp rule

Write behind R_TS

Abort

Abort

Abort

Write behind only W_TS

Abort

Ignore obsolete write

Abort

Uncommitted conflicting write

May be exposed

May be exposed

Access waits

Recoverable by protocol

Not necessarily

Not necessarily

Yes

Waiting and deadlock

No waiting, deadlock-free

No waiting, deadlock-free

Waits, but dependencies follow timestamps

Repeated-restart starvation

Possible

Possible

Possible

Common traps have exact corrections:

Trap

Correction

Larger timestamp means older

Smaller timestamp means older

Compare with the preceding transaction

Compare TS(T) with the item's metadata

Check W_TS first on a write

Check R_TS, then W_TS

Update after rejection or ignore

Make no data or metadata update

Basic TO is automatically recoverable

It can expose an uncommitted value

Thomas ignores every old write

It never ignores an R_TS violation

Questions may ask which transaction aborts, the accepted-operation count, final timestamps, the Thomas outcome, or recoverability. KnowledgeGate has more than 10 practice questions on Timestamp Ordering Protocols. The linked DBMS Transaction MCQs: 12 Solved (ACID, Locking) focus on ACID and locking, while the schedules here drill timestamp-ledger decisions.

Timestamp ordering protocols: the short version and next step

  • Read aborts when TS(T) < W_TS(X).

  • Basic write aborts when TS(T) < R_TS(X) or TS(T) < W_TS(X).

  • Thomas ignores only the second obsolete-write case.

  • Strict TO waits before exposing an uncommitted conflicting write.

An accepted read takes the maximum R_TS; an accepted write sets W_TS; a rejected or ignored operation makes no update. Without looking back, reproduce these checkpoints: (X, R_TS, W_TS) = (140, 25, 20), the Thomas branch keeps Y = 90, W_TS(Y) = 20, and strict TO makes r4(Z) wait while T3 is uncommitted.

Once the ledger is automatic, use the GATE Test Series for timed mixed practice. If transactions, serialisability and recovery need rebuilding as one sequence, follow GATE Guidance by Sanchit Sir.