Reclaiming Old Database Versions

Keep the version each active snapshot can still need and account for the memory effects of long-running readers.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. A version can be obsolete for new reads and necessary for old ones
  2. Cleanup and transaction lifetime affect each other

A version can be obsolete for new reads and necessary for old ones

Suppose a record has committed versions at times five and ten. A reader with snapshot time eight may still need the version at five. Deleting every version earlier than the oldest snapshot timestamp would incorrectly delete it. Instead preserve an appropriate visible predecessor and any versions still needed by active snapshots, replicas or other stated retention obligations.

Cleanup and transaction lifetime affect each other

Long readers can pin old state and cause storage growth even while new updates finish normally. Logs, indexes and historical readers may use distinct retention cutoffs. Chunking maintenance or changing reader lifetimes is a workload choice, while safe reclamation derives from version eligibility. Snapshot isolation explains which version a reader selects. LSM compaction removes versions only when the relevant lower layers and readers no longer require them.[1][2]

References

  1. CMU 15-445/645, Introduction to Database Systems: Lectures ↩
  2. PostgreSQL Global Development Group, PostgreSQL Documentation ↩