Skip to content

Core: Use transaction metadata for post-commit file cleanup - #17708

Open
raunaqmorarka wants to merge 2 commits into
apache:mainfrom
raunaqmorarka:transaction-post-commit-cleanup
Open

Core: Use transaction metadata for post-commit file cleanup#17708
raunaqmorarka wants to merge 2 commits into
apache:mainfrom
raunaqmorarka:transaction-post-commit-cleanup

Conversation

@raunaqmorarka

Copy link
Copy Markdown
Contributor

BaseTransaction resolves its newly committed snapshots through ops.current(), a catalog re-read that can return stale metadata when the catalog caches table pointers. When any new snapshot is missing from the stale view, committedFiles returns null and clean-up of all uncommitted files is skipped ("Failed to load metadata for a committed snapshot, skipping clean-up"). With concurrent writers on a Glue catalog this fired on every commit and leaked one stale manifest list per commit retry attempt.

The transaction's own committed metadata always contains the new snapshots, so resolve them there.

The new test serves stale metadata from current() after a successful commit with injected retries. Without the fix it fails because no uncommitted files are ever deleted.

BaseTransaction resolved its newly committed snapshots through
ops.current(), a catalog re-read that can be stale when the catalog
caches table pointers. A missing snapshot made committedFiles return
null, skipping clean-up of all uncommitted files and leaking one stale
manifest list per commit retry attempt. The transaction's own committed
metadata always contains the new snapshots, so resolve them there.
@github-actions github-actions Bot added the core label Aug 18, 2026
@uros-b

uros-b commented Aug 19, 2026

Copy link
Copy Markdown
Member

+1, LGTM

// committedFiles returns null whenever the set of committed files
// cannot be determined from the provided snapshots
private static Set<String> committedFiles(TableOperations ops, Set<Long> snapshotIds) {
private static Set<String> committedFiles(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like the else block and the return null on line 476 will become unreachable? It's fine if we just want to keep the defensive check there regardless

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right, the ids now come from iterating current.snapshots() and are looked up in the same immutable metadata object, so the null path could never fire. Rather than keep a dead branch, 27b96e1 collects the Snapshot objects directly and passes them to committedFiles, removing the null contract and the unreachable warn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants