Home  

Random  

Nearby  



Log in  



Settings  



Donate  



About Wikipedia  

Disclaimers  



Wikipedia





Timestamp-based concurrency control





Article  

Talk  



Language  

Watch  

Edit  





Incomputer science, a timestamp-based concurrency control algorithm is a optimistic concurrency control method. It is used in some databases to safely handle transactions using timestamps.

Operation

edit

Assumptions

edit

Generating a timestamp

edit

A number of different approaches can generate timestamps

Formal definition

edit

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:

For all  :

For each action  :
If  wishes to read the value of  :
If  then abort (a more recent thread has overwritten the value),
Otherwise update the set of dependencies   and set  ;
If  wishes to update the value of  :
If  then abort (a more recent thread is already relying on the old value),
If  then skip (the Thomas Write Rule),
Otherwise store the previous values,  , set  , and update the value of  .
While there is a transaction in   that has not ended: wait
If there is a transaction in   that aborted then abort
Otherwise: commit.

Toabort:

For each  in 
If  equals   then restore   and  

Informal definition

edit

Whenever a transaction initiated, it receives a timestamp. The transaction's timestamp indicates when the transaction was initiated. These timestamps ensure that transactions affect each object in the same sequence of their respective timestamps. Thus, given two operations that affect the same object from different transactions, 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,

If a transaction wants to write to an object,

Physically unrealizable

edit

The behavior is physically unrealizable if the results of transactions could not have occurred if transactions were instantaneous. The following are the only two situations that result in physically unrealizable behavior:

  1. Transaction T tries to read X but TS(T) < WT(X). Reason: It means that X has been written to by another transaction after T began.
  2. Transaction T tries to write X but TS(T) < RT(X). Reason: It means that a later transaction read X before it was written by T.

Recoverability

edit

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 that 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.

Implementation issues

edit

Timestamp resolution

edit

This is the minimum time elapsed between two adjacent timestamps. If the resolution of the timestamp is too large (coarse), the possibility of two or more timestamps being equal is increased and thus enabling some transactions to commit out of correct order. For example, for a system that creates one hundred unique timestamps per second, two events that occur 2 milliseconds apart may be given the same timestamp even though they occurred at different times.

Timestamp locking

edit

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.

See also

edit

Retrieved from "https://en.wikipedia.org/w/index.php?title=Timestamp-based_concurrency_control&oldid=1214984272"
 



Last edited on 22 March 2024, at 12:32  





Languages

 


Deutsch
فارسی

Українська
 

Wikipedia


This page was last edited on 22 March 2024, at 12:32 (UTC).

Content is available under CC BY-SA 4.0 unless otherwise noted.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Terms of Use

Desktop