The Validation-Based Protocol, also known as Optimistic Concurrency Control (OCC), is a concurrency control technique that assumes transactions rarely conflict with one another. Instead of checking for conflicts during execution, each transaction executes independently and validates its operations before committing.
In this approach, all updates made by a transaction are applied to local copies of data items rather than directly to the database. When the transaction reaches the end of its execution, the validation phase checks whether the transaction can be committed without violating serializability. If validation succeeds, the changes are written to the database; otherwise, the transaction is rolled back and restarted.
Optimistic concurrency control is called optimistic because it assumes that conflicts between transactions are infrequent, reducing the overhead of locking and waiting.
A transaction passes through the following three phases:
In this phase, the transaction reads data items from the database and performs all computations. Any changes are made only to temporary local variables and are not written to the actual database.
In this phase, the system checks whether committing the transaction would violate serializability. The transaction is validated against other concurrently executing transactions to detect possible conflicts.
If the validation phase is successful, the changes stored in local variables are written to the database and the transaction is committed. If validation fails, the transaction is rolled back and restarted.
To perform validation, each transaction is assigned different timestamps that help the system determine whether transactions overlap and whether their execution order preserves serializability. These timestamps are used during the validation process to decide whether a transaction can safely commit.
Start(Ti): It contains the time when Ti started its execution.
Validation (Ti): It contains the time when Ti finishes its read phase and starts its validation phase.
Finish(Ti): It contains the time when Ti finishes its write phase.
A transaction T can complete its validation phase successfully if at least one of the following conditions is satisfied:
When validating a transaction T, the first condition is checked for the preceding transaction. If it is false, only condition 2 is checked. If condition 2 is false, only condition 3 is checked. If any one of these three conditions evaluates to true, there is no conflict and T is successfully validated. The validation phase of transaction T fails if none of these three conditions are true and it is then rolled back and restarted later.
The main idea for using validation based protocol is:
The main disadvantage of using validation based protocols is:
We request you to subscribe our newsletter for upcoming updates.