Validation Based Protocols in DBMS
Validation-based protocols, also known as Optimistic Concurrency Control (OCC), are a set of techniques that aim to increase system concurrency and performance by assuming that conflicts between transactions will be rare. Unlike other concurrency control methods, which try to prevent conflicts proactively using locks or timestamps, OCC checks for conflicts only at transaction commit time.
Here’s how a typical validation-based protocol operates:
- Read Phase
- The transaction reads from the database but does not write to it.
- All updates are made to a local copy of the data items.
- Validation Phase
- Before committing, the system checks to ensure that this transaction's local updates won't cause conflicts with other transactions.
- The validation can take many forms, depending on the specific protocol.
- Write Phase
- If the transaction passes validation, its updates are applied to the database.
- If it doesn't pass validation, the transaction is aborted and restarted.
Validation-based protocols Example
Let’s consider a simple scenario with two transactions \( T1 \) and \( T2 \):
- Both transactions read an item \( A \) with a value of 10.
- \( T1 \) updates its local copy of \( A \) to 12.
- \( T2 \) updates its local copy of \( A \) to 15.
- \( T1 \) reaches the validation phase and is validated successfully (because there's no other transaction that has written to \( A \) since \( T1 \) read it).
- \( T1 \) moves to the write phase and updates \( A \) in the database to 12.
- \( T2 \) reaches the validation phase. The system realizes that since \( T2 \) read item \( A \), another transaction (i.e., \( T1 \)) has written to \( A \). Therefore, \( T2 \) fails validation.
- \( T2 \) is aborted and can be restarted.
Advantages of Validation-based protocols
- High Concurrency: Since transactions don’t acquire locks, more than one transaction can process the same data item concurrently.
- Deadlock-free: Absence of locks means there's no deadlock scenario.
Disadvantages of Validation-based protocols
- Overhead: The validation process requires additional processing overhead.
- Aborts: Transactions might be aborted even if there's no real conflict, leading to wasted processing.
Validation-based protocols work best in scenarios where conflicts are rare. If the system anticipates many conflicts, then the high rate of transaction restarts might offset the advantages of increased concurrency.
Next Topic :Multiple Granularity in DBMS