codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Subjects
🗄️

DBMS

23 chapters

1Intro & 3-Schema Architecture2ER Model & Diagrams3Generalization, Specialization & Aggregation4Relational Model & Codd's Rules5Relational Algebra6Tuple & Domain Relational Calculus7SQL: DDL, DML, DCL8Advanced SQL (Joins, Aggregates)9Views, Triggers & Stored Procedures10Functional Dependencies11Normalization (1NF, 2NF, 3NF)12BCNF & Lossless Decomposition13Transaction Concepts & ACID14Conflict & View Serializability15Concurrency Control & Locks162-Phase Locking (2PL)17Timestamp-Based Protocols18Indexing (Primary, Clustering)19B-Trees & B+ Trees20Hashing Techniques in DBMS21Database Recovery Techniques22NoSQL Databases Overview23Data Warehousing Concepts
SubjectsDBMS

Timestamp-Based Protocols

Updated 2026-05-06
2 min read

Timestamp-Based Protocols

Unlike lock-based protocols (where transactions acquire locks and potentially deadlock), Timestamp-Based Protocols assign a unique timestamp to each transaction when it enters the system. The system uses these timestamps to determine the serialization order, ensuring conflict serializability without any locks.

1. Timestamp Ordering Protocol

Each data item $Q$ maintains two timestamps:

  • W-timestamp(Q): The timestamp of the last transaction that successfully wrote $Q$.
  • R-timestamp(Q): The timestamp of the last transaction that successfully read $Q$.

When Transaction $T_i$ with timestamp $TS(T_i)$ issues an operation:

Read(Q):

  • If TS(T_i) < W-timestamp(Q): $T_i$ is trying to read a value that was already overwritten by a younger transaction. Reject and rollback $T_i$.
  • Otherwise: Allow the read. Update R-timestamp(Q) = max(R-timestamp(Q), TS(T_i)).

Write(Q):

  • If TS(T_i) < R-timestamp(Q): $T_i$ is trying to overwrite a value that a younger transaction already read. Reject and rollback $T_i$.
  • If TS(T_i) < W-timestamp(Q): $T_i$ is trying to write a value that was already overwritten by a younger transaction. Reject and rollback $T_i$.
  • Otherwise: Allow the write. Update W-timestamp(Q) = TS(T_i).

2. Thomas' Write Rule

An optimization of the basic protocol. If TS(T_i) < W-timestamp(Q) for a write operation, instead of rolling back $T_i$, the system simply ignores the write (since it would have been overwritten anyway by the younger transaction). This reduces unnecessary rollbacks.

3. Advantages & Disadvantages

Advantages: Deadlock-free (no locks are used). Guarantees conflict serializability.

Disadvantages: Cascading rollbacks are possible. Starvation can occur if a transaction is repeatedly rolled back and restarted with a new timestamp.

4. Multiversion Concurrency Control (MVCC)

Modern databases (PostgreSQL, MySQL InnoDB, Oracle) use MVCC: each write creates a new version of the data item instead of overwriting it. Readers always see a consistent snapshot based on their transaction's start timestamp, so reads never block writes and writes never block reads.



Previous2-Phase Locking (2PL)NextIndexing (Primary, Clustering)

Recommended Gear

2-Phase Locking (2PL)Indexing (Primary, Clustering)