Course contentsShow
← Computer Science
Lesson 1667 of 2,87238. Database Transactions and IndexingFree lesson

Dirty Reads Problem

Examining scenarios where transactions read uncommitted data from other transactions and the resulting issues.

Dirty Reads Problem

What you'll learn: You'll discover why reading uncommitted data from concurrent transactions can create serious data integrity issues.

What Is a Dirty Read?

A dirty read occurs when one transaction reads data that another transaction has modified but not yet committed. This is the primary risk of the "Read Uncommitted" isolation level you just learned about.

Think of it like reading someone's rough draft before they've finished editing. If they decide to delete entire paragraphs (rollback), you've based your work on information that never actually existed in the final version.

How the Problem Unfolds

Imagine two concurrent transactions:

Transaction A:

  1. Updates an account balance from 1000to1000 to 500 (withdrawing $500)
  2. Has not committed yet

Transaction B:

  1. Reads the same account balance → sees $500
  2. Makes decisions based on $500 (maybe denies a payment request)
  3. Commits successfully

Transaction A:

  1. Encounters an error and rolls back
  2. The balance returns to $1000

Now Transaction B made a real-world decision (denying payment) based on 500,butthebalancewasactually500, but the balance was actually 1000 the whole time. The $500 was "dirty data"—temporary and never truly valid.

Why This Matters

Dirty reads violate the consistency guarantee in ACID. Your application might:

  • Display incorrect information to users
  • Make business decisions on phantom data
  • Create cascading errors across related transactions
  • Generate reports with numbers that never truly existed

Key Takeaway: Dirty reads allow transactions to see uncommitted (potentially invalid) data from other transactions, leading to decisions based on information that may be rolled back and never become permanent in the database.