liveBook · Manning

Dirty read

As explained in Java Persistence with Spring Data and Hibernate epub

A dirty read is a concurrency anomaly in which a transaction reads changes made by another transaction before those changes are committed.

A dirty read occurs when one transaction reads changes made by another transaction before those changes are committed. The value may be invalid because the writing transaction can later roll back. section 11.2.1

Uncommitted transaction data

Transaction 1 changes a database value but has not committed. Transaction 2 reads that changed value, then Transaction 1 rolls back. Transaction 2 has consumed data that was never committed. section 11.2.1

Figure 11.2 Dirty read: Transaction 2 reads uncommitted data from Transaction 1.

Use the transaction timeline to inspect how Transaction 2 observes Transaction 1's uncommitted data. section 11.2.1

Dirty reads are one of several concurrency anomalies, alongside lost updates, unrepeatable reads, and phantom reads. Transaction isolation levels define which anomalies a system prevents, with stronger isolation increasing cost and potentially reducing performance and scalability. section 11.2.1

How Java Persistence with Spring Data and Hibernate epub covers it

How deep it goes
Defines the transaction sequence and rollback danger, then places the anomaly within isolation-level comparisons.
Examples
Uses a two-transaction timeline in which Transaction 2 reads Transaction 1's uncommitted change.
What it assumes
Assumes basic understanding of transactions, commits, rollbacks, and concurrent database access.
What you can do after
Evaluate transaction isolation choices by recognizing when reads can observe data that may later roll back.
How it connects
Connects dirty reads with transactions, transaction isolation levels, rollbacks, lost updates, unrepeatable reads, and phantom reads.

Also explained in

Compare how 2 books explain dirty read →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Java Persistence with Spring Data and Hibernate epub. The section links point to the parts of the book it draws on.