Validation Based Protocol in DBMS
Last Updated :
12 May, 2025
Validation Based Protocol is also called Optimistic Concurrency Control Technique. This protocol is used in DBMS (Database Management System) for avoiding concurrency in transactions. It is called optimistic because of the assumption it makes, i.e. very less interference occurs, therefore, there is no need for checking while the transaction is executed.
Optimistic Concurrency Control Technique
In this technique, no checks are performed during the execution of the transaction. Until the transaction reaches its end, updates are not applied directly to the database. Instead, all updates are made to local copies of the data items maintained for the transaction. At the end of the transaction's execution, a validation phase checks whether any of the transaction’s updates violate serializability. If there is no violation, the transaction is committed and the database is updated. Otherwise, the transaction is aborted and restarted.
Optimistic Concurrency Control is a three-phase protocol. A transaction goes through three phases:
- Read Phase:
- The transaction reads data and performs calculations using temporary (local) variables.
- No changes are made to the database yet.
- Validation Phase:
- Before committing, the transaction checks for conflicts with other concurrently running transactions.
- It validates that executing this transaction won't violate serializability.
- Write Phase:
- If validation passes, the transaction writes changes to the database.
- If validation fails, the transaction is aborted and may be restarted.
The flow diagram below shows the working of the transaction based protocol.
Validation Based protocol
The idea behind optimistic concurrency control is to defer all conflict checks until the end of the transaction, allowing execution to proceed with minimal overhead until the validation phase. If there is little interference among transactions, most validations will succeed. However, if conflicts are common, transactions may frequently fail validation, causing results to be discarded and the transactions to be restarted. These conditions are not favorable for optimization, as the core assumption of low interference is violated.
The validation-based protocol is best suited for environments where conflicts are rare. Since it operates on local copies of data, rollbacks do not affect other transactions, effectively avoiding cascading rollbacks. However, this method is not ideal for long-running transactions, as they are more likely to encounter conflicts with short transactions and may be repeatedly rolled back.
Timestamps Associated with Validation-Based Protocols
Validation based protocols often use timestamps to manage the serialization order of transactions. Key timestamps associated with a transaction Ti include:
- Start (Ti): The time when transaction Ti begins its execution (read phase).
- Validation (Ti): The time when transaction Ti finishes its read phase and starts the validation phase. This timestamp is often used as the timestamp of the transaction for serialization purposes (TS(Ti) = Validation(Ti)).
- Finish (Ti): The time when transaction Ti completes its write phase (if validation is successful).
Two more terms that we need to know are:
- Write_set: A set of transaction that contains all the write operations that Ti performs.
- Read_set: A set of transaction that contains all the read operations that Ti performs.
Transaction Schedule
In the Validation phase for transaction Ti the protocol inspect that Ti doesn't overlap or intervene with any other transactions currently in their validation phase or in committed.
Example : Here two Transactions Ti and Tj are given, 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 |
Analysis
- Both Tj and Ti read the old values (
x = 12
, y = 15
) before any writes occur.
- Ti validates before Tj writes, so it reads consistent, unmodified data.
- Tj’s writes occur only after validation, so there is no conflict during Ti's validation phase.
- Validation succeeds for both transactions:
- Condition 1 applies:
Finish(Tj) < Start(Ti)
is not true. - But Condition 2 applies: Ti’s read set does not intersect with Tj’s write set at the time of validation.
- Both transactions can commit successfully.
Advantages of Validation-Based Protocols
- High Concurrency: Since no locks are acquired during the read phase, multiple transactions can access the same data items concurrently, potentially leading to higher throughput.
- Deadlock-Free: The absence of locks eliminates the possibility of deadlocks.
- No Cascading Rollbacks: Because updates are applied to the database only after successful validation, a transaction’s failure does not cause other transactions that read its (uncommitted) data to rollback.
Disadvantages of Validation-Based Protocols
- Validation Overhead : The validation process itself introduces overhead.
- Transaction Conflicts : If conflicts are frequent, a significant number of transactions might fail validation and need to be restarted which leads to wastage of work and reduced performance.
- Starvation : Long transactions might repeatedly fail validation if shorter transactions, frequently commit before them.
Similar Reads
Participation Constraints in DBMS In DBMS(Database Management Management System), Participation Constraints are rules that govern the minimum and maximum number of entities or relationships that must or may participate in a particular relationship. Within the database structure, these restrictions uphold business standards and guara
6 min read
Data Isolation in DBMS In today's era effectively managing volumes of data is crucial, for businesses and organizations. Database Management Systems (DBMS) play a role in this aspect by providing tools to store, retrieve, and manipulate data. However when multiple users are. Their transactions interact with the data simul
5 min read
Commit Protocol in DBMS This article covers topics related to the database management system. In this article, we will learn about the commit protocols that are in the subject of database management systems. This article then describes the types of Commit protocols in database management systems. It then talks about the ad
5 min read
Transaction in DBMS In a Database Management System (DBMS), a transaction is a sequence of operations performed as a single logical unit of work. These operations may involve reading, writing, updating, or deleting data in the database. A transaction is considered complete only if all its operations are successfully ex
10 min read
Concurrency problems in DBMS Transactions Concurrency control is an essential aspect of database management systems (DBMS) that ensures transactions can execute concurrently without interfering with each other. However, concurrency control can be challenging to implement, and without it, several problems can arise, affecting the consistency
4 min read