Skip to content

fix(table): skip RemoveSnapshotsUpdate when no snapshots to expire - #679

Merged
zeroshade merged 2 commits into
apache:mainfrom
dhananjaykrutika:commit-with-no-updates
Jan 19, 2026
Merged

zeroshade merged 2 commits into
apache:mainfrom
dhananjaykrutika:commit-with-no-updates

Conversation

@dhananjaykrutika

Copy link
Copy Markdown
Contributor

ExpireSnapshots was adding a RemoveSnapshotsUpdate even when there were no snapshots to delete. This caused Commit to create a new metadata file on every call, even when nothing changed, leading to metadata file proliferation in maintenance jobs that leverage iceberg-go's snapshot expiration implementation.

ExpireSnapshots was adding a RemoveSnapshotsUpdate even when there were
no snapshots to delete. This caused Commit to create a new metadata file
on every call, even when nothing changed, leading to metadata file
proliferation in maintenance jobs that leverage iceberg-go's snapshot
expiration implementation.
Comment thread table/transaction.go
Comment on lines +278 to 283
// Only add the update if there are actually snapshots to delete
if len(snapsToDelete) > 0 {
updates = append(updates, NewRemoveSnapshotsUpdate(snapsToDelete))
}

return t.apply(updates, reqs)

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.

We should probably also have a length check on updates and simply return nil if len(updates) == 0

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.

tx.Commit() does check the length of updates before calling table commit & post-commit ops. See https://github.com/apache/iceberg-go/blob/main/table/transaction.go#L551

@zeroshade zeroshade left a comment

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.

Thanks for this!

@zeroshade
zeroshade merged commit 22e34f8 into apache:main Jan 19, 2026
11 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.

3 participants