Thomas write rule


In computer science, particularly the field of databases, the Thomas write rule is a rule in timestamp-based concurrency control. It can be summarized as ignore outdated writes.
It states that, if a more recent transaction has already written the value of an object, then a less recent transaction does not need perform its own write since it will eventually be overwritten by the more recent one.
The Thomas write rule is applied in situations where a predefined logical order is assigned to transactions when they start. For example a transaction might be assigned a monotonically increasing timestamp when it is created. The rule prevents changes in the order in which the transactions are executed from creating different outputs: The outputs will always be consistent with the predefined logical order.
For example consider a database with 3 variables, and two atomic operations C := A, and C := B. Each transaction involves a read, and a write. The only conflict between these transactions is the write on C. The following is one possible schedule for the operations of these transactions:
If T1 is assigned a timestamp that precedes T2, then only T2's write should be visible. If, however, T1's write is executed after T2's write, then we need a way to detect this and discard the write.
One practical approach to this is to label each value with a write timestamp that indicates the timestamp of the last transaction to modify the value. Enforcing the Thomas write rule only requires checking to see if the write timestamp of the object is greater than the time stamp of the transaction performing a write. If so, the write is discarded
In the example above, if we call TS the timestamp of transaction T, and WTS the write timestamp of object O, then T2's write sets WTS to TS. When T1 tries to write C, it sees that TS < WTS, and discards the write. If a third transaction T3 > TS) were to then write to C, it would get TS > WTS, and the write would be allowed.