Main Page | See live article | Alphabetical index

Timestamp-based concurrency control

In computer science, in the field of databases, timestamp-based concurrency control is a non-lock concurrency control method, used in relational databases to safely handle transactions, using timestamps.

Each transaction can be assigned a timestamp at startup, so we can ensure that if an action Ai of a transaction Ti conflicts with action Aj of a transaction Tj, action Ai occurs before action Aj if TS(transaction Ti) < TS(transaction Aj). If an action violates the order, the transaction is aborted and restarted.

Every database object O is given a read timestamp RTS(O) and a write timestamp WTS(O).

If a transaction T wants to read O, and TS(T) < WTS(O), the order of the read with respect to the most recent write on O would violate the timestamp order between transaction and writer. So, T is aborted and restarted with a new, larger timestamp. If a transaction T wants to read O, and TS(T) > WTS(O), T reads O, RTS(O) is set to max[RTS(O), TS(T)].

If a transaction T wants to write O, if TS(T) < RTS(O), the write action would conflict with the read action of O and T is aborted and restarted.

If a transaction T wants to write O, if TS(T) < WTS(O), we use the Thomas Write Rule and ignore this write to O and continue.

Otherwise, T writes to O, and WTS(O) is set to TS(T).