Open In App

Thomas Write Rule in DBMS

Last Updated : 05 Feb, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In a Database Management System (DBMS), transactions follow certain rules to ensure data consistency and correctness. When a user executes a command that modifies the database (such as an update or delete statement), the DBMS must ensure that the change is permanently saved to disk before the user is allowed to continue with other actions. This ensures that the database remains consistent and durable, even in the event of system failures or crashes. One such rule is the Thomas Write Rule, which is an improvement over the Basic Timestamp Ordering Protocol. In the Timestamp Ordering Protocol, if a transaction tries to write outdated data, it is usually rejected and rolled back to maintain serializability. However, not all outdated writes cause conflicts, and some can be safely ignored without affecting correctness.

Thomas Write Rule allows such harmless outdated writes to be ignored instead of rolling back the transaction, increasing concurrency. Unlike other protocols that enforce conflict serializability, Thomas Write Rule allows view serializable schedules, making transaction processing more flexible and efficient.

Key Conditions

The Thomas Write Rule modifies the Basic Timestamp Ordering Protocol by allowing certain outdated writes instead of rolling back transactions. It follows these three conditions when handling write operations (W_item(X)):

Abort Condition (Reject the Transaction): If R_TS(X) > TS(T) (i.e., the read timestamp of X is greater than the timestamp of transaction T), Abort and rollback transaction T, as a newer version of X has already been read, and writing an outdated value could lead to inconsistency.

Ignore Outdated Writes (Allow Execution Without Writing): If W_TS(X) > TS(T) (i.e., the write timestamp of X is greater than T’s timestamp), Ignore the write operation but continue processing the transaction.

Execute Write Operation (Normal Execution): If neither condition (1 or 2) occurs, then:

  • Perform W_item(X) (write operation).
  • Update W_TS(X) = TS(T) to reflect the latest write timestamp.

Outdated Write

The main improvement in Thomas Write Rule is that it ignores obsolete (outdated) writes instead of rejecting transactions. This happens when a newer transaction has already updated a value, making the older transaction’s write operation unnecessary.

Example-

Consider two transactions:

  • T1 arrives after T2, meaning TS(T2) < TS(T1).
  • This implies that the serial execution order must be:
    T2 → T1 (T2 should execute before T1).

Schedule Execution:

Step Operation Description
1 T2: W2(X) T2 writes X (sets W_TS(X) = TS(T2))
2 T1: W1(X) T1 tries to write X (TS(T1) > W_TS(X))
3 T1’s write is ignored Since T2 has already written X, T1’s write is obsolete and ignored instead of rollback
  • In Basic Timestamp Ordering, T1 would abort because its write is considered outdated.
  • In Thomas Write Rule, outdated writes are ignored instead of rollback, allowing T1 to continue execution.

Consider the partial schedule given below:

Example of Outdated Write

Example of Outdated Write

Obsolete Writes are hence ignored in this rule which is in accordance with the 2nd protocol. It seems to be more logical as users skip an unnecessary procedure of restarting the entire transaction. This protocol is just a modification to the Basic TO protocol. 

T1 T2
R(A)  
  W(A)
  Commit
W(A)  
Commit  

The above table is showing a Serializable Schedule that is not a Conflict Serializable.

T1 T2
R(A) Commit
W(A)  
Commit  

The above table is showing a Conflict Serializable Schedule.

Features of Thomas Write Rule

The Thomas Write Rule, also known as the Write-Ahead Logging (WAL) protocol, has several key features that make it an important principle of database management systems:

  • Durability: The Thomas Write Rule ensures that any modifications to the database are permanently saved to disk before the transaction is considered complete. This means that even in the event of a system failure or crash, the database can be recovered to a consistent state.
  • Atomicity: The Thomas Write Rule is part of a larger principle of atomicity, which states that a transaction must either be complete in its entirety or be completely rolled back in the event of an error. By ensuring that modifications to the database are written to disk before a transaction is considered complete, the Thomas Write Rule helps to enforce atomicity.
  • Concurrent Access: The Thomas Write Rule allows multiple users to access the database concurrently, while still ensuring that the database remains consistent and durable. This is accomplished through a variety of mechanisms, such as locking and transaction isolation levels.
  • Performance: While the Thomas Write Rule does require that changes be written to disk before control is returned to the user, modern database systems are able to optimize the process to minimize the impact on performance. For example, many systems use a technique called “write-ahead logging” to batch changes together and write them to disk in an efficient manner.

Difference Between Basic TO Protocol and Thomas Write Rule

Suppose a user has a schedule in which two transactions T1 and T2. Now, TS(T2) < TS(T1). This implies that the serializability of the schedule allowed is T2 –> T1. Consider the two protocols, and let us see what types of Operations will be allowed and not allowed under them. Ri(A) implies Read and Wi(A) implies Write operation. Now, let us look at the types of partial schedules allowed in both Basic TO and Thomas Write Rule, you’ll understand the difference in operations of both protocols. User distinguish in operations Allowed and Not Allowed in both of the Protocols. 

Basic TO Protocol Thomas Write Rule
  • Not Allowed 
    • R1(X) W2(X)
    • W1(X) R2(X)
    • W1(X) W2(X)
  • Allowed 
    • All operations where T2 occurs before T1.
    • R1(X) R2(X)
  • Not Allowed 
    • R1(X) W2(X)
    • W1(X) R2(X)
  • Allowed 
    • All operations where T2 occurs before T1.
    • Outdated Writes: W1(X) W2(X)
    • R1(X) R2(X)

FAQs on Thomas Write Rule in DBMS

What is the Thomas Write Rule in DBMS?

The Thomas Write Rule is a modification of the Basic Timestamp Ordering Protocol that ignores outdated writes instead of rejecting transactions. It improves concurrency by allowing view serializable schedules even if they are not conflict serializable.

How does the Thomas Write Rule improve concurrency?

Instead of aborting transactions with outdated writes, it ignores those writes and allows the transaction to continue. This prevents unnecessary rollbacks and increases the number of concurrent transactions that can be processed.

What are the three main conditions of the Thomas Write Rule?

  1. Abort if an outdated read occurs → If a transaction reads an already updated value, it must be aborted.
  2. Ignore outdated writes → If a transaction tries to write an old value that has already been updated, the write is ignored.
  3. Execute only valid writes → If neither of the above conditions applies, the write is executed normally, and the write timestamp is updated.

How does the Thomas Write Rule differ from Basic Timestamp Ordering Protocol?

  • Basic Timestamp Ordering: Rejects all outdated writes and forces a rollback.
  • Thomas Write Rule: Ignores outdated writes but still maintains database consistency.

Is the Thomas Write Rule always conflict serializable?

No, Thomas Write Rule does not enforce Conflict Serializability but ensures View Serializability. This means some schedules that are not conflict serializable can still be allowed under Thomas Write Rule while maintaining correctness.



Next Article

Similar Reads