Concurrency control by validation

advertisement
Concurrency control by
validation
Concurrency control by validation
•
•
•
•
Architecture of Validation based scheduler
The validation rules
Comparison of three concurrency-control mechanism
Exercises
How can concurrency control be performed
with validation?
• In this method, transactions are allowed to access data
without locks.
• At the appropriate time a check is performed that the
transaction has behaved in a serializable manner.
• Just before a transaction starts to write values of
database elements, it goes through a “validation phase”.
• In this phase the risk of a physically unrealizable
behavior is checked, if a risk exists the transaction is
rolled back.
• The above processes are taken care of, by a validation
scheduler.
Validation-Based scheduler
• The validation-based scheduler must know the following:
* The set of database elements the transaction T reads.
* The set of database elements T writes.
• T executes in three phases:
* Read – elements are read into read set RS(T) and
local address space for write is calculated.
* Validate – Validation of clashing elements with other
transactions is done.
* Write – transaction writes elements to write set WS(T)
Validation based Scheduler sets
• Validation based scheduler assumed serial order of
transactions.
• It maintains three sets of transactions:
– START( ): set of T’s started but not completed
validation.
– VAL( ): set of T’s validated but not finished the writing
phase.
– FIN( ): set of T’s that have finished.
Potential problems with validation scheduler
• Case 1:
– U is in VAL or FIN; that is, U has validated,
– FIN(U)>START(T); that is, U did not finish before T started
– RS(T) ∩WS(T) ≠φ; let it contain database element X.
Since in this case we don’t know if T got to read the value that U wrote, we must roll
back T to avoid the risk that the actions of T and U will not be consistent with the
assumed serial order.
Potential problems with validation scheduler
• Case 2:
- U is in VAL; U has successfully validated.
- FIN(U)>VAL(T); U did not finish before T entered its validation phase.
- WS(T) ∩ WS(U) ≠φ; let x be in both write sets.
T and U must both write values of X and if we let T validate, it is
possible that it will write X before U does. Since we cannot be sure,
we rollback T to make sure it does not violate the assumed serial
order in which it follows U.
Sample Problem
Solution
• Validation of U:
Nothing to check
• Validation of T:
WS(U) ∩ RS(T)= {D} ∩{A,B}=φ
WS(U) ∩ WS(T)= {D}∩ {A,C}=φ
• Validation of V:
RS(V) ∩ WS(T)= {B}∩{A,C}=φ
WS(V) ∩ WS(T)={D,E}∩ {A,C}=φ
RS(V) ∩ WS(U)={B} ∩{D}=φ
• Validation of W:
RS(W) ∩ WS(T)= {A,D}∩{A,C}={A}
RS(W) ∩ WS(V)= {A,D}∩{D,E}={D}
WS(W) ∩ WS(V)= {A,C}∩{D,E}=φ (W is not validated)
Thank You
Download