• Dirty Read assumes uncommitted writes are visible to others i.e. T1 writes some value in its own local work…
vipintewatia·
• Dirty Read assumes uncommitted writes are visible to others i.e. T1 writes some value in its own local workspace and even without Commit it is viewable in Database’s shared memory.
• Lost Update assumes uncommitted writes are not visible, but concurrent updates overwrite each other due to lack of synchronization.
So why these assumptions vary?
Comments
KG AI MentorKG AI Mentor
Great question — it's a common point of confusion when learning about database concurrency issues. The reason the assumptions for Dirty Read and Lost Update differ lies in how the database system handles isolation and visibility of uncommitted changes, and what kind of concurrency problem we're trying to model. Let’s break it down: --- 🔹 1. Dirty Read: Assumes uncommitted writes are visibleWhat it means: Transaction T1 writes a value, but hasn't committed yet. Another transaction T2 reads that value. Why this assumption? This models a scenario where the isolation level is too low — specifically, Read Uncommitted. Database behavior: In this isolation level, uncommitted changes are visible to other transactions. Example: - T1: UPDATE account SET balance = 100 WHERE id = 1 (not committed) - T2: SELECT balance FROM account WHERE id = 1 → sees 100 - If T1 later rolls back, T2 read a value that never existed — a dirty read. ✅ So, Dirty Read assumes visibility of uncommitted writes because it's about reading data that might be rolled back. --- 🔹 2. Lost Update: Assumes uncommitted writes are NOT visibleWhat it means: Two transactions read the same data, modify it, and write back — but one overwrites the other’s changes. Why this assumption? This models a scenario where each transaction sees only committed data, but they don’t coordinate. Database behavior: The system enforces visibility only of committed data (e.g., Read Committed or higher), but lacks proper synchronization (like locking or optimistic concurrency control). Example: - T1: Reads balance = 100 (committed) - T2: Reads balance = 100 (committed) - T1: Updates balance to 150 - T2: Updates balance to 200 - Result: T1’s update is lost — final value is 200, not 150 + 100. ✅ So, Lost Update assumes uncommitted writes are NOT visible because it's about conflicting updates on the same data, where both transactions see the same "snapshot" of the data before any write. --- 🔹 Why the assumptions differ?| Aspect | Dirty Read | Lost Update | |-------|------------|-------------| | Visibility of uncommitted data | ✅ Visible | ❌ Not visible | | Isolation level | Read Uncommitted | Read Committed or higher | | Core issue | Reading "dirty" (uncommitted) data | Overwriting changes due to lack of coordination | | Cause | Weak isolation | Lack of synchronization (e.g., no locks) | --- 🧠 Key Insight:Dirty Read is about reading uncommitted data — so it assumes data is visible. Lost Update is about overwriting committed data — so it assumes only committed data is visible, but no protection against concurrent modifications. They model different failure modes under different isolation levels. --- ✅ Summary:> The assumptions vary because Dirty Read and Lost Update are distinct concurrency anomalies that occur under different isolation behaviors: > - Dirty Read happens when uncommitted data is visible (low isolation). > - Lost Update happens when uncommitted data is not visible, but concurrent updates conflict (higher isolation, but no synchronization). So, the difference isn't a contradiction — it's a reflection of how isolation levels and concurrency control mechanisms interact. — KG AI Mentor 🤖
@vipintewatia Dirty Read assumes uncommitted writes are visible to others (as in Read Uncommitted isolation), while Lost Update assumes they are not directly visible but concurrent updates overwrite each other due to lack of synchronization. The difference comes from isolation level assumptions.