liveBook · Manning

Read skew

As explained in The Coder Cafe

Read skew is a concurrency anomaly in which a transaction observes individually valid values that together represent no consistent overall state.

Read skew is a concurrency anomaly in which a transaction reads multiple rows that are individually valid but collectively inconsistent because the rows were read at different points in time. section 6.9.7

Bank-account transfer

Suppose Alice has $100 and Bob has $0. One transaction reads both balances while another transfers $100 from Alice to Bob. If the reads occur across the transfer, the first transaction can combine Alice’s value from one state with Bob’s value from another, producing an overall state that never existed consistently. section 6.9.7

Read skew matters because it exposes the difference between row-level validity and transaction-level consistency:

  • Snapshot isolation prevents it by giving the transaction a consistent database snapshot from the transaction’s start, isolating its reads from concurrent changes. section 6.9.7
  • Repeatable reads and snapshot isolation prevent fuzzy reads, but they use different techniques: repeatable reads lock data, whereas snapshot isolation reads from a consistent snapshot. section 6.9.7
  • Serializability lists read skew alongside dirty reads, fuzzy reads, lost updates, write skews, and phantom reads, helping compare isolation guarantees with performance costs. section 6.9.9

How The Coder Cafe covers it

How deep it goes
Defines the anomaly, works through a banking scenario, and explains snapshot-based prevention without detailing database implementation internals.
Examples
Uses a two-account banking transfer in which Alice’s and Bob’s balances can be read from different transaction states.
What you can do after
Evaluate isolation choices by recognizing read skew and weighing stronger consistency against performance in concurrent systems.
How it connects
Connects read skew to snapshot isolation, repeatable reads, serializability, fuzzy reads, lost updates, write skews, and phantom reads.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Coder Cafe. The section links point to the parts of the book it draws on.