When multiple transactions execute concurrently in an uncontrolled or unrestricted manner, then it might lead to several problems. These problems are commonly referred to as concurrency problems in database environment. The five concurrency problems that can occur in database are:
(i). Temporary Update Problem (ii). Incorrect Summary Problem (iii). Lost Update Problem (iv). Unrepeatable Read Problem (v). Phantom Read Problem
These are explained as following below.
- Temporary Update Problem:
Temporary update or dirty read problem occurs when one transaction updates an item and fails. But the updated item is used by another transaction before the item is changed or reverted back to its last value.
In the above example, if transaction 1 fails for some reason then X will revert back to its previous value. But transaction 2 has already read the incorrect value of X.
- Incorrect Summary Problem:
Consider a situation, where one transaction is applying the aggregate function on some records while another transaction is updating these records. The aggregate function may calculate some values before the values have been updated and others after they are updated.
In the above example, transaction 2 is calculating the sum of some records while transaction 1 is updating them. Therefore the aggregate function may calculate some values before they have been updated and others after they have been updated.
- Lost Update Problem:
In the lost update problem, update done to a data item by a transaction is lost as it is overwritten by the update done by another transaction.
In the above example, transaction 1 changes the value of X but it gets overwritten by the update done by transaction 2 on X. Therefore, the update done by transaction 1 is lost.
- Unrepeatable Read Problem:
The unrepeatable problem occurs when two or more read operations of the same transaction read different values of the same variable.
In the above example, once transaction 2 reads the variable X, a write operation in transaction 1 changes the value of the variable X. Thus, when another read operation is performed by transaction 2, it reads the new value of X which was updated by transaction 1.
- Phantom Read Problem:
The phantom read problem occurs when a transaction reads a variable once but when it tries to read that same variable again, an error occurs saying that the variable does not exist.
In the above example, once transaction 2 reads the variable X, transaction 1 deletes the variable X without transaction 1’s knowledge. Thus, when transaction 2 tries to read X, it is not able to it.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Concurrency Control in DBMS
- Lock Based Concurrency Control Protocol in DBMS
- Graph Based Concurrency Control Protocol in DBMS
- Lightweight Transactions in Cassandra
- Recovery With Concurrent Transactions
- Two Phase Locking (2-PL) Concurrency Control Protocol | Set 3
- Timestamp based Concurrency Control
- Concurrency Control Techniques
- Concurrency in Operating System
- How to solve Relational Algebra problems for GATE
- Decidable and Undecidable problems in Theory of Computation
- Practice Problems on Hashing
- Redundant Link problems in Computer Network
- Practice problems on finite automata
- Practice problems on finite automata | Set 2
- Computable and non-computable problems in TOC
- How to solve RSA Algorithm Problems?
- Problems with Token Ring
- Classical problems of Synchronization with Semaphore Solution
- Stop and Wait protocol, its problems and solutions
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.