![]() |
VOOZH | about |
Validation-Based Protocol, also known as Optimistic Concurrency Control, is a technique in DBMS used to manage concurrent transactions without locking data during execution. It assumes that conflicts between transactions are rare and delays conflict detection until the validation phase just before committing.
This protocol operates in three main phases:
1. Read Phase:
2. Validation Phase:
3. Write Phase:
The diagram below shows the working of the transaction based protocol.
Validation-based protocol delays conflict checks until the end. It works well in systems where most transactions don’t interfere with each other.
Validation based protocols often use timestamps to manage the serialization order of transactions. Each transaction Ti is associated with three important timestamps:
Two more terms that we need to know are:
Let’s consider two transactions where Tj starts before Ti, since TS(Tj) < TS(Ti) so the validation phase succeeds in the Schedule A. It's noted that the final write operations to the database are performed only after the validation of both Ti and Tj. Since Ti reads the old values of x(12) and y(15) while print (x+y) operation unless final write operation take place.
| Time | Tj (Earlier TS) | Ti (Later TS) | Notes |
|---|---|---|---|
| T0 | r(x) → x = 12 | Ti starts and reads x = 12 | |
| T1 | r(x) → x = 12 | Tj starts and reads x = 12 | |
| T2 | x = x - 10 | Tj computes new value for x | |
| T3 | r(y) → y = 15 | Ti reads y | |
| T4 | y = y + 10 | Ti computes new value for y | |
| T5 | r(x) | Tj re-reads x (local copy still 12) | |
| T6 | <validate> | Ti enters validation phase | |
| T7 | print(x + y) → 27 | Uses local x = 12, y = 15 | |
| T8 | <validate> | Tj enters validation phase | |
| T9 | w(x) | Tj writes x | |
| T10 | w(y) | Tj writes y |
x = 12, y = 15) before any writes occur.For Ti to successfully validate against Tj, the following two conditions should meet: