MVCC garbage collection

DesignHard50 min

Your task

An MVCC database (think Postgres-style) is accumulating dead row versions: tables and indexes keep growing far beyond the live data, sequential scans get slower, and the autovacuum/GC process can't keep up. Investigation shows occasional long-running read transactions (analytics queries, a stuck connection holding a snapshot) that run for tens of minutes. Design the version garbage-collection / vacuum subsystem and explain precisely why long-running readers cause unbounded bloat and how you bound it without breaking snapshot reads.

It covers

  • Garbage collection
  • Long running readers
  • Bloat