Skip to content

Support retainLast and setMinSnapshotsToKeep Snapshot Retention Policies #2150

@ForeverAngry

Description

@ForeverAngry

Feature Request / Improvement

Overview

Add richer snapshot expiration retention capabilities:

  • retain_last_n(n): keep N most recent snapshots regardless of age.
  • older_than_with_retention(...): combine max age filter with retain_last_n and a minimum snapshots floor.
  • with_retention_policy(...): unified API that also consumes table property defaults:
    • history.expire.max-snapshot-age-ms
    • history.expire.min-snapshots-to-keep
    • history.expire.max-ref-age-ms (plumbed for future ref expiration logic)
      Internal helpers:
  • _get_expiration_properties: parses table properties.
  • _get_snapshots_to_expire_with_retention: core selection logic factoring protected refs (branches/tags), age, recency, and minimum keep guardrail.
    Motivation: safer, configurable space reclamation while preventing accidental over‑expiration.

Related to #2369

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions