mzzz-zzm commented on code in PR #982:
URL: https://github.com/apache/iceberg-go/pull/982#discussion_r3202200437
##########
table/snapshot_producers.go:
##########
@@ -815,12 +815,52 @@ func (sp *snapshotProducer) summary(props
iceberg.Properties) (Summary, error) {
}, previousSummary)
}
+// computeOwnManifests returns the subset of allManifests that were written
+// by this producer (i.e. not inherited from the parent snapshot). These are
+// preserved across OCC retry attempts when the manifest list is rebuilt
+// against a fresh parent.
+func (sp *snapshotProducer) computeOwnManifests(allManifests
[]iceberg.ManifestFile) []iceberg.ManifestFile {
+ if sp.parentSnapshotID <= 0 {
+ // No parent means all manifests are new — nothing to exclude.
+ return allManifests
+ }
+
+ parent, err := sp.txn.meta.SnapshotByID(sp.parentSnapshotID)
+ if err != nil || parent == nil {
Review Comment:
The signature is now `([]iceberg.ManifestFile, error)`. All three error
paths return `nil, err` (or a wrapped error for the missing-parent case) rather
than `allManifests`:
```go
parent, err := sp.txn.meta.SnapshotByID(sp.parentSnapshotID)
if err != nil {
return nil, fmt.Errorf("computeOwnManifests: lookup parent snapshot %d:
%w", sp.parentSnapshotID, err)
}
if parent == nil {
return nil, fmt.Errorf("computeOwnManifests: parent snapshot %d not
found", sp.parentSnapshotID)
}
parentManifests, err := parent.Manifests(sp.io)
if err != nil {
return nil, fmt.Errorf("computeOwnManifests: read parent manifests: %w",
err)
}
```
The `parentSnapshotID <= 0` early return (`return allManifests, nil`) is
unchanged — that is the valid all-new case for a new table.
The call site in `commit()` now checks the error and aborts:
```go
ownManifests, err := sp.computeOwnManifests(newManifests)
if err != nil {
return nil, nil, err
}
```
Tests added: `TestComputeOwnManifests_NewTable`,
`TestComputeOwnManifests_SnapshotByIDError`,
`TestComputeOwnManifests_ParentManifestsIOError`.
--
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]