Skip to content

feat(transaction): add ExpireSnapshotsAction#2591

Open
dhruvarya-db wants to merge 1 commit into
apache:mainfrom
dhruvarya-db:feat-expire-snapshots-action
Open

feat(transaction): add ExpireSnapshotsAction#2591
dhruvarya-db wants to merge 1 commit into
apache:mainfrom
dhruvarya-db:feat-expire-snapshots-action

Conversation

@dhruvarya-db
Copy link
Copy Markdown

@dhruvarya-db dhruvarya-db commented Jun 5, 2026

Which issue does this PR close?

Revives the effort to close #2145 (originally filed as #1454), which has been attempted before but never landed. This is the first of a small series of PRs and covers the metadata-only piece; physical file cleanup will build on top of it in follow-ups.

What changes are included in this PR?

Adds an ExpireSnapshotsAction to the transaction API, reachable as tx.expire_snapshots() and following the same convention as the other actions. It selects the snapshots to expire and emits a single RemoveSnapshots update. It deliberately does not touch any files; that is left to a follow-up so this change stays small and easy to review.

Selection mirrors Java's RemoveSnapshots. Explicit ids (expire_snapshot_ids) and age-based expiry (expire_older_than_ms) are combined rather than mutually exclusive: a snapshot is expired if it is named explicitly or is older than the cutoff. retain_last keeps the most recent snapshots even when older than the cutoff and only bounds the age path. Any snapshot referenced by a branch or tag (including the current snapshot) is protected from expiry, and naming such an id explicitly is an error, since TableMetadataBuilder::remove_snapshots would otherwise drop the ref silently. Per-ref retention windows (max-snapshot-age, max-ref-age, per-branch min-snapshots-to-keep) are left for a later PR.

Are these changes tested?

Yes. Unit tests cover explicit-id expiry, age filtering with retain_last, unknown ids being ignored, and that the action registers on a transaction, plus the ref-safety behavior: the current snapshot and a tagged snapshot cannot be expired explicitly, and age-based expiry skips a tagged snapshot.

@dhruvarya-db dhruvarya-db force-pushed the feat-expire-snapshots-action branch 3 times, most recently from fce97ed to 9b45819 Compare June 5, 2026 01:21
Add a metadata-only transaction action that removes snapshots, emitting a
single RemoveSnapshots update. Physical file cleanup is left to a follow-up
maintenance operation built on top of this action.

Ref apache#1454
@dhruvarya-db dhruvarya-db force-pushed the feat-expire-snapshots-action branch from 9b45819 to 0bdd123 Compare June 5, 2026 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ExpireSnapshotsAction for snapshot lifecycle management

2 participants