Skip to content

fix(table): read retention table properties as defaults in ExpireSnapshots#877

Merged
zeroshade merged 2 commits into
apache:mainfrom
alliasgher:fix-expire-snapshots-table-props
Apr 13, 2026
Merged

fix(table): read retention table properties as defaults in ExpireSnapshots#877
zeroshade merged 2 commits into
apache:mainfrom
alliasgher:fix-expire-snapshots-table-props

Conversation

@alliasgher
Copy link
Copy Markdown
Contributor

Summary

ExpireSnapshots required callers to always pass WithRetainLast and WithOlderThan; it never consulted the table-level retention properties (min-snapshots-to-keep, max-snapshot-age-ms, max-ref-age-ms), even though their keys and defaults are defined in properties.go. Tables that set these properties via a catalog would not honor them during snapshot expiry, diverging from the Java implementation.

Fix: read the three retention properties from table metadata and use them as the last-resort fallback in the cmp.Or chains for maxRefAgeMs, minSnapshotsToKeep, and maxSnapshotAgeMs. When a property is absent the math.MaxInt constants apply, preserving current behaviour for callers that pass explicit options.

Fixes #839

Test plan

  • go test ./...
  • gofmt -l clean
  • New test TestExpireSnapshotsUsesTableProperties: creates a table with min-snapshots-to-keep=2 and max-snapshot-age-ms=0 set as properties, calls ExpireSnapshots() with no options, and asserts exactly 2 snapshots survive.

Signed-off-by: Ali alliasgher123@gmail.com

…shots

ExpireSnapshots required the caller to always pass WithRetainLast and
WithOlderThan; it never consulted the table-level retention properties
(min-snapshots-to-keep, max-snapshot-age-ms, max-ref-age-ms), even
though their keys and defaults are defined in properties.go. This meant
tables that set these properties via a catalog would not honor them
during snapshot expiry, diverging from the Java implementation.

Read the three retention properties from table metadata and use them as
the last-resort fallback in the cmp.Or chains for maxRefAgeMs,
minSnapshotsToKeep, and maxSnapshotAgeMs. When a property is absent the
existing math.MaxInt constants apply, preserving current behaviour for
callers that pass explicit options.

Adds TestExpireSnapshotsUsesTableProperties which calls ExpireSnapshots
with no options and verifies that the table-property defaults are
respected.

Fixes apache#839

Signed-off-by: Ali <alliasgher123@gmail.com>
Copy link
Copy Markdown
Contributor

@laskoviymishka laskoviymishka left a comment

Choose a reason for hiding this comment

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

Thanks for contribution! Good fix: ExpireSnapshots should read table-level retention properties as defaults, matching Java.

Two nits: removing the error returns is a silent behavioral change, and the test has a couple of rough edges.

Comment thread table/transaction.go
Comment thread table/table_test.go Outdated
…operties

Setting max-ref-age-ms to its own default value had no effect and
obscured the test's intent. The test now proves that an absent property
correctly falls back to the math.MaxInt default, which is the actual
behaviour being verified.

Signed-off-by: Ali <alliasgher123@gmail.com>
@laskoviymishka
Copy link
Copy Markdown
Contributor

@tanmayrauth can you review this one, and close #883 as dupe?

@zeroshade zeroshade merged commit a002b13 into apache:main Apr 13, 2026
13 checks passed
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.

fix: read snapshot retention properties as defaults in ExpireSnapshots

3 participants