---
title: "Short note: Timestamp ordering in CC"
subject: "Distributed System"
chapter: 8
key: "semester_7/distributed_system:timestamp-ordering-note"
source: https://www.bctengineer.com/q/semester_7/distributed_system/timestamp-ordering-note
site: BCT Engineering
---

# Short note: Timestamp ordering in CC

Distributed System · Chapter 8: Transaction and Concurrency Control

- Asked in: 2070 Chaitra, 3 marks
- Video: [Lec-105: Basic Timestamp Ordering Protocol with Example in Hindi | Concurrency Control | DBMS](https://www.youtube.com/watch?v=27NtGV1vNoY) — Gate Smashers
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/distributed_system/timestamp-ordering-note
- Whole chapter: https://www.bctengineer.com/md/semester_7/distributed_system/chapter-8

## Question

Write a short note on timestamp ordering in concurrency control.

## Short answer

Timestamp ordering gives each transaction a unique timestamp. Objects track last read/write timestamps; a transaction's operation is allowed only if its timestamp is later than the object's write timestamp and any reads. Violations cause abort and restart, avoiding deadlocks but possibly causing restarts.

## Answer

**Timestamp ordering** gives each transaction a unique timestamp when it starts (a Lamport clock or a global timestamp from server id and local clock in a distributed system). Conflicting operations are executed in timestamp order, so the result is equivalent to running transactions serially in timestamp order. No locks are used, so no deadlock.

Each object keeps a **write timestamp** (of the last committed write) and **read timestamps** (of transactions that read it). For a transaction T with timestamp Tc:
- **Write rule**: T's write is allowed only if Tc ≥ the maximum read timestamp of the object and Tc > the write timestamp of the committed version. Otherwise T is aborted (it would invalidate a later read).
- **Read rule**: T's read is allowed if Tc > the write timestamp of the committed version; if a tentative version from an earlier transaction exists, T waits until it commits or aborts. If Tc is smaller than the write timestamp, T is too late and is aborted.

An aborted transaction restarts with a new, later timestamp. Timestamp ordering is deadlock-free, but it causes restarts; keeping multiple versions of objects reduces the number of aborts.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What does timestamp ordering ensure?
   A. Transactions use locks in timestamp order
   B. Conflicting operations are executed in timestamp order, equivalent to a serial order by timestamp
   C. Deadlock is detected using wait-for graphs
   D. Every transaction commits
   Answer: B. No locks are used; operations are ordered by transaction timestamps. (Key point: Core idea)

2. When is T's write rejected (T aborted)?
   A. Tc is greater than all read timestamps
   B. Tc is less than the maximum read timestamp (a later transaction already read the object)
   C. Tc equals zero
   D. The object has no tentative version
   Answer: B. Such a write would invalidate a read already done by a later transaction. (Key point: Write rule)

3. How is an aborted transaction restarted under timestamp ordering?
   A. With the same timestamp
   B. With a new, later timestamp
   C. Without a timestamp
   D. With the smallest timestamp in the system
   Answer: B. Restarting with the old timestamp would conflict again, so a new later timestamp is assigned. (Key point: Restart)

## Related in Distributed System

- [Flat/nested transactions; concurrency control](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Aflat-nested-cc-methods) — Distributed System, chapter 8
- [Concurrency control goals and mechanisms](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Acc-goals-mechanisms) — Distributed System, chapter 8
- [Concurrency control methods compared](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Acc-methods-compare) — Distributed System, chapter 8
- [Distributed concurrency control methods](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Adistributed-cc-methods) — Distributed System, chapter 8
- [Flat/nested transactions; optimistic CC](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Aflat-nested-optimistic) — Distributed System, chapter 8
- [Nested transactions; optimistic CC advantages](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Anested-optimistic-advantages) — Distributed System, chapter 8

## Related in other subjects

- [Rolled vs normal concrete; CC pavement construction](https://www.bctengineer.com/question.md?key=semester_7%2Ftransportation_engineering_ii%3Arolled-concrete-cc-pavement-construction) — Transportation Engineering II, chapter 3
