- DBMS Tutorial
- DBMS - Home
- DBMS - Overview
- DBMS - Architecture
- DBMS - Data Models
- DBMS - Data Schemas
- DBMS - Data Independence
- Entity Relationship Model
- DBMS - ER Model Basic Concepts
- DBMS - ER Diagram Representation
- DBMS - Generalization, Aggregation
- Relational Model
- DBMS - Codd's Rules
- DBMS - Relational Data Model
- DBMS - Relational Algebra
- DBMS - ER to Relational Model
- DBMS- SQL Overview
- Relational Database Design
- DBMS - Database Normalization
- DBMS - Database Joins
- Storage and File Structure
- DBMS - Storage System
- DBMS - File Structure
- Indexing and Hashing
- DBMS - Indexing
- DBMS - Hashing
- Transaction And Concurrency
- DBMS - Transaction
- DBMS - Concurrency Control
- DBMS - Deadlock
- Backup and Recovery
- DBMS - Data Backup
- DBMS - Data Recovery
- DBMS Useful Resources
- DBMS - Quick Guide
- DBMS - Useful Resources
- DBMS - Discussion
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.
- Related Articles
- 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?
- On Line Transaction Processing (OLTP) System in DBMS
- What are the different ways the transaction can be executed(DBMS)?
- Explain check pointing in the transaction management system(DBMS)
- What is a shielded transaction?
- Explain serial execution or transaction with an example(DBMS)
- How LOST UPDATE and DIRTY READ impact the processing of a COBOL-DB2 program?
- What is a 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 will happen to the current MySQL transaction if a START TRANSACTION command is executed in the middle of that current transaction?