recall

← recall

MVCC pattern

Database keeps multiple versions of each row, tagged by transaction id. Readers see the version that was committed when their transaction started; writers create new versions. Snapshot isolation falls out naturally; readers never block writers and vice versa.

Database keeps multiple versions of each row, tagged by transaction id. Readers see the version that was committed when their transaction started; writers create new versions. Snapshot isolation falls out naturally; readers never block writers and vice versa.

symptoms

  • need readers + writers without blocking
  • long-running reads need a consistent view

causes

  • locking-only schemes serialize everything
  • need predictable read latency under write load

fixes

  • MVCC with periodic vacuum to reclaim old versions
  • choose isolation level wisely (snapshot vs serializable)

you might say

  • MVCC
  • snapshot reads
  • multi-version

related

aliases: multi-version concurrency control

topics: databases, postgres

references: