Thomas Write Rule

Amisha Purswani
Last Updated: May 13, 2022

Introduction

The Thomas write rule is a concurrency control mechanism used in database management systems to sustain and manage concurrent transactions and processes. It is an improved version of the timestamp ordering protocol used for concurrency control. The Thomas writes rule is based on the process of ignoring out-of-date writes. It holds all the timestamping protocol's characteristics, manages the concurrent transactions associated with conflict serializability, and views serializability scenarios. It is a helpful protocol for concurrent transactions associated with a preset logical order from the start and mapped with the appropriate timestamp rules.

Thomas Write Rule

Thomas' write rule allows schedules that do not conflict serializable but are correct. Those non-conflict-serializable schedules satisfy the definition of view serializable schedules. The Thomas' write rule is a concurrency control modification of the timestamp-ordering protocol. The Thomas write rule is applied when a predefined logical order is assigned to transactions when they start.

We can ignore the write operation under the following conditions to increase the concurrency.

These conditions are as follows- 

Suppose that Transaction ‘Ti’ issues Write(Q)

    1. If Ts(Ti)< R(Q)

If the timestamp of Ti is less than R(Q), It implies that the value of Q that Ti is creating was previously required, and that value was never supposed to be produced.

Hence, in this case, the system rejects, and Ti is rolled back.

     2.   If Ts(Ti)<W(Q)

If the timestamp of Ti is less than W(Q), then it means that Ti is attempting to write an absolute value of Q. Hence this write operation can be ignored.

     3.  Otherwise, in all the cases, the system executes write operation and sets W(Q) to Ts(Ti).

The rule prohibits various outputs generated by changes when transactions are completed. The outputs will always be in the same logical sequence as the inputs.

As an example:

Consider a database containing three variables (A, B, and C), as well as two atomic operations (C:= A (T1) and (C:= B (T2) ). A read and a write are needed for each transaction (C).

If  T1 is assigned a timestamp that precedes T2, only T2's write should be visible. However, we need to detect this and discard the write if T1's write is executed after T2's write.

One approach to this is to label each with a write timestamp (WTS) which symbolizes the timestamp of the last transaction to change the value. Enforcing the Thomas write rule requires checking if the object's write timestamp is larger than the timestamp of the transaction performing a write. If so, the write is discarded.

Advantages

  • Thomas write rule assures view serializability by preserving and controlling the concurrent transaction's write operation schedules.
  • Based on the write operation performed by the most recent transaction, the data object will be updated with the most recent absolute values.
  • Thomas' write rule helps maintain data consistency in the serializable schedule transaction systems.
  • The Thomas write rule uses Timestamp order to maintain the check condition and regulate the write operations that modify the values of the data object in the database management system.
  • It provides a superior concurrency control technique in a database management system, ensuring efficient data consistency.

Disadvantage

  • It does not ensure the concurrent transaction's conflict serializability. However, it attempts to keep the view serializability schedule by neglecting the transaction's obsolete write operations.

FAQs

  1. Which condition is valid for Thomas' write rule?
    The Thomas write rule is applied when a predefined logical order is assigned to transactions when they start.
     
  2. What is a timestamp?
    A timestamp is a unique identifier produced by the database management system to identify the transaction's relative start time.
     
  3. What is a transaction?
    A transaction is a logical unit of work that reads and modifies the contents of a database in some instances. Transactions employ read and write operations to access data. Specific characteristics are followed before and after a transaction to maintain database consistency.

Key Takeaways

We learned about Thomas' Write rule and its advantages and disadvantages in this blog. Thomas write rules is a modified version of the timestamp ordering protocol.

The Thomas Write Rule guarantees the protocol's serializability order. The Basic Timestamp Ordering Algorithm gets more enhanced.

Also, try CodeStudio to practice programming problems for your complete interview preparation. Ninja, don't stop here; check out the Top 100 SQL Problems to get hands-on experience with frequently asked interview questions and land your dream job.

Was this article helpful ?
1 upvote

Comments

No comments yet

Be the first to share what you think