hcrosse commented on code in PR #2351:
URL: https://github.com/apache/iceberg-go/pull/2351#discussion_r4418692941
##########
table/transaction.go:
##########
@@ -909,7 +909,15 @@ func (t *Transaction) ExpireSnapshots(opts
...ExpireSnapshotsOpt) error {
// Only add the update if there are actually snapshots to delete
if len(snapsToDelete) > 0 {
- updates = append(updates,
NewRemoveSnapshotsUpdate(snapsToDelete, cfg.postCommit))
+ // Build can set the last-updated time, but only apply may
change the
+ // transaction's builder.
+ planned, err := meta.clone().Build()
Review Comment:
Agreed, thanks. I replaced the full metadata copy with the cleanup record.
##########
table/updates.go:
##########
@@ -664,30 +675,16 @@ func (u *removeSnapshotsUpdate) PostCommit(ctx
context.Context, preTable *Table,
filesToDelete := make(map[string]struct{})
- for _, snapId := range u.SnapshotIDs {
- snap := preTable.Metadata().SnapshotByID(snapId)
- if snap == nil {
- return errors.New("snapshot should never be nil")
+ var expired []*Snapshot
+ for _, u := range removals {
+ if !u.postCommit {
Review Comment:
Thanks, I agree. I added the test for expirations with and without cleanup.
##########
table/transaction.go:
##########
@@ -2662,11 +2670,20 @@ func (t *Transaction) Commit(ctx context.Context)
(*Table, error) {
// otherwise a retry would re-run the catalog commit.
t.committed = true
+ var removals []*removeSnapshotsUpdate
for _, u := range meta.updates {
+ if removal, ok := u.(*removeSnapshotsUpdate); ok {
+ removals = append(removals, removal)
+
+ continue
+ }
if perr := u.PostCommit(ctx, t.tbl, tbl); perr != nil {
err = errors.Join(err, perr)
}
}
+ if perr := deleteExpiredFiles(ctx, t.tbl, tbl, removals...);
perr != nil {
Review Comment:
I linked [#2354](https://github.com/apache/iceberg-go/pull/2354), which
fixes the retry error and closes #2339, in this PR's description.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]