liveBook · Manning

Nonrepeatable read

As explained in Java Persistence with Spring Data and Hibernate epub

An unrepeatable read is a transaction anomaly in which a repeated read of the same data returns a different value because another transaction committed a modification.

A nonrepeatable read occurs when one transaction reads the same data item twice but receives different values because another transaction committed an update between the reads. section 11.2.1

Changed value during one transaction

Transaction 1 reads the highest bid. Transaction 2 updates and commits that bid. When Transaction 1 reads it again, the value has changed, producing a nonrepeatable read. section 11.2.1

Figure 11.3 Unrepeatable read: The highest bid changed while Transaction 1 was in execution.

Shows the highest bid changing while the first transaction remains in execution. section 11.2.1

Isolation levels address this anomaly at different costs:

  • READ_COMMITTED permits nonrepeatable reads. section 11.2.1
  • REPEATABLE_READ prevents nonrepeatable reads, while SERIALIZABLE also prevents phantom reads. section 11.2.1

How Java Persistence with Spring Data and Hibernate epub covers it

How deep it goes
Defines the anomaly and demonstrates its timing, then compares isolation levels without detailing database locking internals.
Examples
Uses a highest-bid value read twice while another transaction updates and commits it between reads.
What it assumes
Assumes basic transactions and concurrent reads, while defining nonrepeatable reads alongside related anomalies.
What you can do after
Evaluate isolation choices by determining whether they prevent nonrepeatable reads and what performance costs higher isolation brings.
How it connects
Connects nonrepeatable reads with transactions, dirty reads, phantom reads, lost updates, and transaction isolation levels.

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.