- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is dirty read in a transaction(DBMS)?
When many transactions are executed simultaneously then we call them concurrent transactions. Concurrency is required to increase time efficiency. If there are many transactions which are trying to access the same data, then inconsistency arises. Concurrency control is required to maintain consistency of data.
In order to run transactions concurrently, we interleave their operations. Each transaction gets a share of computing time.
Problems in transactions
This leads to the following problems −
- Lost update problem. ( WW conflict)
- Dirty read / temporary update. ( WR conflict)
- Unrepeatable read / incorrect analysis problem. (RW conflict)
All these arise because isolation is broken.
Let us discuss the dirty read or temporary update.
Dirty read is a read of uncommitted data. If a particular row is modified by another running application and not yet committed, we also run an application to read the same row with the same uncommitted data. This is the state we say it as a dirty read.
The one main thing is that the dirty reader has to stop reading dirty.
We can try to use the shared locks to prevent other transactions to modify the row, if one is carried out here.
Example of dirty read problem
Step 1 − Consider we have an online shopping system where users can buy and view the buyer products at the same time.
Step 2 − Let us suppose a case in which a user tries to buy a product , and as soon as the user buys the product then the count value in update stock will change immediately.
Step 3 − Let us consider that there were 10 items in stock, but now they are 9.
Step 4 − Moreover due to this transaction, there will also be communication with the billing gateway.
Step 5 − Meanwhile, if there is any other user who has also done a transaction at the same time, the new user will be able to see 9 items in the stock.
Step 6 − But, let us suppose that the first user was unable to complete his/her transactions due to some error or insufficient funds.
Step 7 − Then, in this case the transaction done by the first user will roll back and now the value in stock will be 10 again.
Step 8 − But, when the 2nd user was doing a transaction the no items in stocks were 9.
Step 9 − This is called DIRTY DATA and this whole problem is called the Dirty Problem.
Consider another example
Let T2 read the update value of X made by T1, but T1 fails and rolls back. So, T2 read an incorrect value of X.
- What is transaction processing? Explain the properties of the transaction(DBMS)
- What are the states of transaction in DBMS?
- What are different transaction isolation levels in DBMS?
- What is a database(dbms)?
- What are the different ways the transaction can be executed(DBMS)?
- How LOST UPDATE and DIRTY READ impact the processing of a COBOL-DB2 program?
- Explain check pointing in the transaction management system(DBMS)
- What is a multimedia database (DBMS)?
- What is a Data Model in DBMS?
- What is a composite attribute in DBMS?
- What is a query language in DBMS?
- What is a materialized view in DBMS?
- What is Decomposition in DBMS?
- What is 4NF in DBMS?
- What is RAID in DBMS?