feat(transaction): add ExpireSnapshotsAction#2591
Open
dhruvarya-db wants to merge 1 commit into
Open
Conversation
fce97ed to
9b45819
Compare
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
9b45819 to
0bdd123
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
ExpireSnapshotsActionto the transaction API, reachable astx.expire_snapshots()and following the same convention as the other actions. It selects the snapshots to expire and emits a singleRemoveSnapshotsupdate. 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_lastkeeps 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, sinceTableMetadataBuilder::remove_snapshotswould 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.