Skip to content

feat(transaction): default expiry to history.expire.* table properties - #2664

Merged
blackmwk merged 1 commit into
apache:mainfrom
dhruvarya-db:feat-expire-snapshots-table-property-defaults
Jun 17, 2026
Merged

blackmwk merged 1 commit into
apache:mainfrom
dhruvarya-db:feat-expire-snapshots-table-property-defaults

Conversation

@dhruvarya-db

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

What changes are included in this PR?

Defaults snapshot expiry to the table's history.expire.* properties when the corresponding knob is not set explicitly, completing the default fallback that #2591 deferred (its plan() carried two TODOs for exactly this).

  • TableProperties gains three fields (and their consts/defaults), in the same shape as the existing commit.retry.* properties:
    • history.expire.max-snapshot-age-ms (default 5 days)
    • history.expire.min-snapshots-to-keep (default 1)
    • history.expire.max-ref-age-ms (default i64::MAX, i.e. never)
  • ExpireSnapshotsAction::plan() now mirrors Java RemoveSnapshots' constructor:
    • the age cutoff defaults to now - max-snapshot-age-ms, so age-based selection always runs even for an explicit-id-only call (only file cleanup, out of scope here, keys off an explicit id in Java);
    • retain_last defaults to min-snapshots-to-keep;
    • refs without their own max_ref_age_ms age out against max-ref-age-ms (default never).

Defaults and names mirror Java's TableProperties (MAX_SNAPSHOT_AGE_MS_DEFAULT = 5 days, MIN_SNAPSHOTS_TO_KEEP_DEFAULT = 1, MAX_REF_AGE_MS_DEFAULT = Long.MAX_VALUE).

Are these changes tested?

Yes — unit tests in expire_snapshots.rs (27 total, up from 25). Two new tests cover the always-on default cutoff (a >5-day-old snapshot is expired with no args while a recent one is kept) and the history.expire.min-snapshots-to-keep floor (the whole chain is retained despite age). Explicit-id-only tests pin the cutoff off to isolate that behavior now that the default age path always runs. public-api.txt regenerated for the new public fields/consts; clippy and fmt are clean.

Add the history.expire.max-snapshot-age-ms / min-snapshots-to-keep / max-ref-age-ms
properties to TableProperties (same shape as commit.retry.*). The expire action now
falls back to these when a knob is not set explicitly, mirroring Java RemoveSnapshots'
constructor: the cutoff defaults to now - max-snapshot-age-ms (5 days) so age-based
selection always runs, retain_last defaults to min-snapshots-to-keep, and refs without
their own max_ref_age_ms age out against max-ref-age-ms (Long.MAX_VALUE, i.e. never).

Completes the history.expire.* default fallback deferred by apache#2591. Ref apache#2145
@dhruvarya-db
dhruvarya-db force-pushed the feat-expire-snapshots-table-property-defaults branch from 58c07ff to 6144e10 Compare June 17, 2026 01:53

@blackmwk blackmwk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dhruvarya-db for this pr!

@blackmwk
blackmwk merged commit 1311892 into apache:main Jun 17, 2026
21 checks passed
amogh-jahagirdar pushed a commit that referenced this pull request Jun 23, 2026
…ots (#2667)

## Which issue does this PR close?

Part of #2145. Extends #2591 (the `ExpireSnapshotsAction`) and #2664
(the `history.expire.*` defaults).

## What changes are included in this PR?

When `ExpireSnapshotsAction` expires snapshots, it now also drops the
statistics and partition-statistics metadata entries tied to each
expired snapshot, mirroring Java `RemoveSnapshots`
(`TableMetadata.Builder.removeSnapshots`, which calls
`removeStatistics`/`removePartitionStatistics` for each removed
snapshot). For every expired snapshot that has a statistics entry,
`commit()` emits a `RemoveStatistics` update; likewise
`RemovePartitionStatistics` for a partition-statistics entry. Only
entries that actually exist produce an update, matching Java's behavior
of recording a change only when an entry is present.

This is metadata-only, physical deletion of the puffin files those
entries point at is part of the file-cleanup maintenance operation
(mirroring Java's `FileCleanupStrategy`), not this PR.

## Are these changes tested?

Yes. New unit tests cover: an expired snapshot's statistics and
partition-statistics entries are removed while a retained snapshot keeps
its own; an expired snapshot with no statistics emits no removal; and
only the statistics variant that is actually present is removed.

---------

Co-authored-by: Dhruv Arya <[email protected]>
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.

3 participants