CS Atlas GATE 2027
DBMS course
0 / 119 complete

DBMS/Phase 6 · Transactions & Concurrency

Lesson 6.7.1 · Item 110 of 119

Timestamp ordering protocol; Thomas write rule

Read at your own pace. Try the questions before opening the answers.

On this page

0 · Recall Warm-up

Answer from memory first. Answers are in the Answer Vault at the bottom.

  1. Under wound-wait, what happens when an older transaction requests an item held by a younger one? from Lesson 6.6.4
  2. What does 2PL guarantee, and what does it not? from Lesson 6.6.2
  3. What is a blind write? from Lesson 6.4.3

1 · The Hook

Locks make transactions wait, and waiting can deadlock. Timestamp ordering never makes anyone wait for a lock: every transaction gets a timestamp at birth, and the DBMS simply insists that conflicting operations happen in timestamp order. An operation that arrives "too late" aborts its transaction, which restarts with a new timestamp. GATE traces these rules step by step.

2 · Predict First

TS(T1) = 1, TS(T2) = 2. Schedule: R1(A) W2(A) W1(A). Under timestamp ordering, which operation fails, and why?

Make a guess in your head. The answer opens Section 3.

3 · Core Concept

Predict First — the answer

W1(A) fails. T2 (younger) has already written A (WTS(A) = 2). Letting the older T1 write now would put T1's write after T2's, against timestamp order. T1 is aborted. (With the Thomas write rule, W1(A) is instead simply ignored.)

Timestamps

  • Each transaction Ti gets a unique timestamp TS(Ti) when it starts (older = smaller).
  • Each data item X keeps RTS(X) (largest TS of any transaction that read X) and WTS(X) (largest TS of any transaction that wrote X).

Basic timestamp ordering (TO) protocol

Ti issues read(X):

  • If TS(Ti) < WTS(X): a younger transaction already overwrote X; Ti needs an older value → abort Ti (roll back, restart with a new timestamp).
  • Otherwise: execute; RTS(X) = max(RTS(X), TS(Ti)).

Ti issues write(X):

  • If TS(Ti) < RTS(X): a younger transaction already read X; Ti's write is too late → abort Ti.
  • Else if TS(Ti) < WTS(X): a younger transaction already wrote X → abort Ti (basic TO).
  • Otherwise: execute; WTS(X) = TS(Ti).

Thomas write rule

Modify the second write check: if TS(Ti) < WTS(X) (and TS(Ti) ≥ RTS(X)), ignore the write instead of aborting. The write is obsolete: a younger transaction has already written a newer value that nobody older has read.

Properties

PropertyBasic TOTO + Thomas rule
Serializableconflict serializable (in timestamp order)view serializable (may be non-CS)
Deadlocknever (no waiting)never
Starvationpossible (a transaction can keep aborting)possible
Recoverable / cascadelessnot guaranteed (needs extra rules, e.g. strict TO)not guaranteed

Some schedules are allowed by 2PL but not TO, and vice versa.

Worked trace

TS(T1) = 10, TS(T2) = 20. Initially RTS = WTS = 0 for A and B.

OperationCheckResultRTS / WTS after
R1(A)10 ≥ WTS(A) = 0okRTS(A) = 10
R2(A)20 ≥ 0okRTS(A) = 20
W2(A)20 ≥ RTS 20, 20 ≥ WTS 0okWTS(A) = 20
W1(A)10 < RTS(A) = 20abort T1
R2(B)20 ≥ 0okRTS(B) = 20

T1 aborts (the lost-update pattern is refused).

4 · Visual

TS order:   older (small TS) ............................ younger (large TS)

read(X) by Ti :  TS(Ti) < WTS(X)  -> abort (value already overwritten by younger)
write(X) by Ti:  TS(Ti) < RTS(X)  -> abort (younger already read the old value)
                 TS(Ti) < WTS(X)  -> abort      (Thomas: ignore the write)
otherwise: do it and update RTS / WTS

5 · Worked Examples

Example 1 Easy

TS(T1) = 5. RTS(X) = 3, WTS(X) = 7. T1 issues read(X). Result?

Solution

5 < WTS 7 → abort T1.

Example 2 Medium

TS(T1) = 5. RTS(X) = 3, WTS(X) = 7. T1 issues write(X). Result under basic TO and under the Thomas write rule?

Solution

5 ≥ RTS 3, but 5 < WTS 7. Basic TO: abort. Thomas: ignore the write and continue.

Example 3 GATE

TS(T1) = 1, TS(T2) = 2, TS(T3) = 3. Schedule R1(A) W3(A) R2(A) W1(B). Under basic TO, which operations succeed?

Solution

R1(A): ok, RTS(A) = 1. W3(A): 3 ≥ RTS 1, 3 ≥ WTS 0 → ok, WTS(A) = 3. R2(A): 2 < WTS(A) = 3 → abort T2. W1(B): ok. So R1(A), W3(A), W1(B) succeed; T2 aborts.

6 · GATE Traps

  • Read check uses WTS; write check uses RTS then WTS.
  • Aborted transactions restart with a new (larger) timestamp in TO.
  • TO is deadlock-free but can starve and is not automatically recoverable.
  • Thomas write rule only changes the "write after a younger write" case, from abort to ignore; reads are unchanged.
  • TO + Thomas allows some view-serializable schedules that are not conflict serializable.

7 · Memory Hook

"Read late? Too late if someone younger already wrote. Write late? Too late if someone younger already read (or wrote: Thomas just shrugs)."

8 · Connect the Dots

Chapter 6.6 controlled concurrency with locks; this lesson did it with timestamps. Last lesson of the phase: three brief topics: locking at several granularities, optimistic validation, and log-based recovery.

9 · Self-Test

GATE format. Try every question before opening the vault.

Q1 · MCQ · 1 mark(s) — Read rule

Under basic TO, Ti's read(X) is rejected when:

  1. (A) TS(Ti) < RTS(X)
  2. (B) TS(Ti) < WTS(X)
  3. (C) TS(Ti) > WTS(X)
  4. (D) RTS(X) = 0

Q2 · MCQ · 2 mark(s) — Thomas

TS(T1) = 4. RTS(X) = 2, WTS(X) = 6. T1 issues write(X). With the Thomas write rule:

  1. (A) T1 aborts
  2. (B) the write is ignored
  3. (C) T1 waits
  4. (D) the write is executed and WTS(X) = 4

Q3 · MSQ · 2 mark(s) — Properties

Which are true of basic timestamp ordering?

  1. (A) It guarantees conflict serializability.
  2. (B) It guarantees recoverable schedules.
  3. (C) It never causes deadlock.
  4. (D) A transaction may starve.

Q4 · NAT · 2 mark(s) — Trace

TS(T1) = 1, TS(T2) = 2. Under basic TO, schedule R2(A) W1(A) R1(B) W2(B). How many transactions abort?

Numerical answer: ________

Q5 · MCQ · 2 mark(s) — Trace

TS(T1) = 10, TS(T2) = 20. Schedule W2(A) R1(A). Under basic TO:

  1. (A) both succeed
  2. (B) T1 aborts at R1(A)
  3. (C) T2 aborts at W2(A)
  4. (D) R1(A) is ignored

10 · Rule Card

  • TS(Ti) at start; RTS(X), WTS(X) per item.
  • read(X): abort if TS < WTS(X); else RTS = max(RTS, TS).
  • write(X): abort if TS < RTS(X); abort if TS < WTS(X) (Thomas: ignore); else WTS = TS.
  • Basic TO: CS, deadlock-free, starvation possible, not necessarily recoverable. Thomas: VS schedules allowed.

11 · Concept Ledger

Unlocked in this lesson. From here on, these terms may be used.

timestamp ordering (TO)TS(Ti)read timestamp RTS(X)write timestamp WTS(X)TO read and write rulesThomas write ruleobsolete write

12 · Answer Vault

Reveal answers when you’re ready

Recall Warm-up

  1. The older wounds (rolls back) the younger.
  2. Conflict serializability; not freedom from deadlock.
  3. A write of an item the transaction did not read first.

Self-Test

Q1 Answer: (B) · 1 mark(s)

A younger transaction already overwrote X.

  • (A) is wrong: That check is for writes.
  • (C) is wrong: That is the allowed case.
  • (D) is wrong: Irrelevant.

Re-read: Lesson 6.7.1 — Timestamp ordering protocol; Thomas write rule

Q2 Answer: (B) · 2 mark(s)

TS < WTS and TS ≥ RTS → obsolete write, ignored.

  • (A) is wrong: Basic TO behaviour.
  • (C) is wrong: TO never waits.
  • (D) is wrong: Would break timestamp order.

Re-read: Lesson 6.7.1 — Timestamp ordering protocol; Thomas write rule

Q3 Answer: (A) (C) (D) · 2 mark(s)

Recoverability needs extra rules.

  • (B) is wrong: Not guaranteed.

Re-read: Lesson 6.7.1 — Timestamp ordering protocol; Thomas write rule

Q4 Answer: 1 · 2 mark(s)

R2(A): RTS(A) = 2. W1(A): 1 < RTS 2 → abort T1. R1(B) skipped (T1 aborted). W2(B): ok.

Re-read: Lesson 6.7.1 — Timestamp ordering protocol; Thomas write rule

Q5 Answer: (B) · 2 mark(s)

10 < WTS(A) = 20.

  • (A) is wrong: The read is too late.
  • (C) is wrong: W2(A) is fine.
  • (D) is wrong: Reads are never ignored.

Re-read: Lesson 6.7.1 — Timestamp ordering protocol; Thomas write rule

Ready for the next idea?

Mark this item complete when you’ve finished reading and working through it.