Home »
DBMS
Concurrency and Problems Due to Concurrency in DBMS
DBMS | Concurrency: In this tutorial, we will learn about the concurrency in DBMS, advantages of concurrency, and problems due to concurrency.
By Prerana Jain Last updated : May 31, 2023
What is Concurrency in DBMS?
The ability of a database system which handles simultaneously or a number of transactions by interleaving parts of the actions or the overlapping this is called concurrency of the system.
Advantages of Concurrency
The good is to serve many users and provides better throughput by sharing resources.
- Reduced waiting time response time or turn around time.
- Increased throughput or resource utilization
- If we run only one transaction at a time than the acid property is sufficient but it is possible that when multiple transactions are executed concurrently than database may become inconsistent.
- Overlapping with the input-output activity with CPU also makes the response time better.
- But interleaving of instruction between transaction may also lead to many problems due to which concurrency control is required.
Problems Due to Concurrency
There are many which may occur due to concurrency,
1) Dirty read problem
If a transaction reads an uncommitted temporary value written by some other transaction than it is called dirty read problem. In this one transaction read a data item updated by another uncommitted transaction that may be future be aborted or failed. In such cases, the read value disappears from the database upon abort this is turned on dirty read the reading transaction end with incorrect results.
Example
T1 T2
R(A)
W(A)
R(A)
The values of item x which is read by T2 is called dirty read data because this data can be created by a transactions that has not been committed yet.
2) Loss update problem/ write - write problem
This problem occur when two transactions access the same data item and have their operations interleaved in a way that makes the value of some database items incorrect.
If there are two write operations of the different transaction on some data values and in between them there are no read operations then the second write over the first .consider the schedule below,
Example
T1 T2
R(A)
W(A)
W(A)
Here is a blind write that means write without a read. Here the changes made by transaction T1 are lost which is updated by a transaction T2.
3) Unrepeatable and phantom read problem
When a transaction cannot repeat the read instructions because the variable is deleted by some other transaction then this problem is called phantom read problem. In this problem at different instances of time a transaction read gives different values it is because data item might have been updated by another transaction.
This causes a problem while execution of some aggregate by a transaction and due to changes in the values of the data item by another transaction it leads to incorrect results. When a transaction read values of data item twice and another transaction's updates data item in between then the results of two read operations will differ.
Example
T1 T2
R(A)
R(A)
Delete(A)
R(A)
4) Incorrect summary problem
When one of the transactions is checking on aggregate summary function while other transactions are updating then this problem is called incorrect summary problem. The aggregate functions may calculate some values before they updated and others after they are updated.