- read-set(T): Each data items that are read by a transaction T
- Timestamps: for all transaction T, the start-time and the end time are reserved for all the three phases.
Let us show this scheme here with the help of the following examples:
Consider the set for transaction T1 and T2.
T1
|
T2
|
Phase
|
Operation
|
Phase
|
Operation
|
-
|
-
|
Read
|
Reads the read set (T2). Let say variables X and Y and
performs updating of local values
|
Read
|
Reads the read set (T1) lets
say variable X and Y and performs updating of local values
|
-
|
-
|
Validate
|
Validate the values of (T1)
|
-
|
-
|
-
|
-
|
Validate
|
Validate the values of (T2)
|
Write
|
Write the updated values in
the database and commit
|
-
|
-
|
-
|
-
|
Write
|
Write the updated values in the
database and commit
|
In this given instance both T1 and T2 get committed. Please note that Read set of T1 and Read Set of T2 are both disjoint, also the Write sets are also disjoint and therefore no concurrency related problem can happen.
T1
|
T2
|
T3
|
Operation
|
Operation
|
Operation
|
Read R(A)
|
--
|
--
|
--
|
Read R(A)
|
--
|
--
|
--
|
Read (D)
|
--
|
--
|
Update(D)
|
--
|
--
|
Update (A)
|
--
|
--
|
Validate (D,A) finds OK
Write (D,A), COMMIT
|
--
|
Validate(A):Unsuccessful
Value changed by T3
|
--
|
Validate(A):Unsuccessful
Value changed by T3
|
--
|
--
|
ABORT T1
|
--
|
--
|
--
|
Abort T2
|
--
|
In this scheme both T1 and T2 get aborted as they fail during validate phase whereas only T3 is committed. Optimistic concurrency control performs its checking at the transaction commits point in a validation phase. The serialization order is defined by the time of transaction validation phase.