Each transaction is an ordered list of actions. Before the transaction performs its first action, it is marked with the current timestamp, or any other strictly totally ordered sequence:. Every transaction is also given an initially empty set of transactions upon which it depends,, and an initially empty set of old objects which it updated,. Each object in the database is given two timestamp fields which are not used other than for concurrency control: is the time at which the value of object was last used by a transaction, is the time at which the value of the object was last updated by a transaction. For all : To abort:
Informal
Whenever a transaction begins, it receives a timestamp. This timestamp indicates the order in which the transaction must occur, relative to the other transactions. So, given two transactions that affect the same object, the operation of the transaction with the earlier timestamp must execute before the operation of the transaction with the later timestamp. However, if the operation of the wrong transaction is actually presented first, then it is aborted and the transaction must be restarted. Every object in the database has a read timestamp, which is updated whenever the object's data is read, and a write timestamp, which is updated whenever the object's data is changed. If a transaction wants to read an object,
but the transaction started before the object's write timestamp it means that something changed the object's data after the transaction started. In this case, the transaction is canceled and must be restarted.
and the transaction started after the object's write timestamp, it means that it is safe to read the object. In this case, if the transaction timestamp is after the object's read timestamp, the read timestamp is set to the transaction timestamp.
If a transaction wants to write to an object,
but the transaction started before the object's read timestamp it means that something has had a look at the object, and we assume it took a copy of the object's data. So we can't write to the object as that would make any copied data invalid, so the transaction is aborted and must be restarted.
and the transaction started before the object's write timestamp it means that something has changed the object since we started our transaction. In this case we use the Thomas write rule and simply skip our write operation and continue as normal; the transaction does not have to be aborted or restarted
otherwise, the transaction writes to the object, and the object's write timestamp is set to the transaction's timestamp.
Recoverability
Note that timestamp ordering in its basic form does not produce recoverable histories. Consider for example the following history with transactions and : This could be produced by a TO scheduler, but is not recoverable, as commits even though having read from an uncommitted transaction. To make sure the it produces recoverable histories, a scheduler can keep a list of other transactions each transaction has read from, and not let a transaction commit before this list consisted of only committed transactions. To avoid cascading aborts, the scheduler could tag data written by uncommitted transactions as dirty, and never let a read operation commence on such a data item before it was untagged. To get a strict history, the scheduler should not allow any operations on dirty items.
This is the minimum time elapsed between two adjacent timestamps. If the resolution of the timestamp is too large, the possibility of two or more timestamps being equal is increased and thus enabling some transactions to commit out of correct order. For example, assuming that we have a system that can create one hundred unique timestamps per second, and given two events that occur 2 milliseconds apart, they will probably be given the same timestamp even though they actually occurred at different times.
Timestamp locking
Even though this technique is a non-locking one, in as much as the Object is not locked from concurrent access for the duration of a transaction, the act of recording each timestamp against the Object requires an extremely short duration lock on the Object or its proxy.