Skip to content

fix(table): ensure manifest length matches file size - #439

Merged
zeroshade merged 2 commits into
apache:mainfrom
zeroshade:manifest-length-size
May 27, 2025
Merged

zeroshade merged 2 commits into
apache:mainfrom
zeroshade:manifest-length-size

Conversation

@zeroshade

Copy link
Copy Markdown
Member

fixes #438

We need to ensure that we flush the manifest that we're writing before we construct the ManifestFile object we want to add to the snapshot so that our length is correct when we write the manifest list itself. This change adds unit tests to ensure that the lengths match up correctly with what we write, and also ensures the tests work on windows (ran into some problems when putting this PR together that I had to fix).

@zeroshade
zeroshade requested review from Fokko and kevinjqliu May 24, 2025 20:47
@zeroshade

Copy link
Copy Markdown
Member Author

@alexandre-normand @alexjo2144 can one or both of you please try out this PR and confirm it fixes your issue? I added tests and hit the spots I could find, but it would be great to get confirmation from you guys too.

@alexandre-normand

alexandre-normand commented May 24, 2025 •

Copy link
Copy Markdown
Contributor

@alexandre-normand @alexjo2144 can one or both of you please try out this PR and confirm it fixes your issue? I added tests and hit the spots I could find, but it would be great to get confirmation from you guys too.

I'll run a test with this version now and report back in a few hours (it won't take that long to get results but I need to walk out and I'll be back on the computer later). Thanks for the prompt fix, @zeroshade!

@alexandre-normand

Copy link
Copy Markdown
Contributor

Confirmed the manifest's length matches the actual file size in s3 now. Querying the manifests from trino now shows files that aren't all the same fixed length (which we had previously) and we can confirm that the latest manifest has a size that matches the manifest length.

Screenshot 2025-05-24 at 4 44 25 PM
2025-05-24 16:42:03      35680 ./<obfucated_file_name-m1.avro

I am getting an error in querying the data from Trino now (which is actually an improvement over silently not getting any rows) but I suspect that it might be something on my end. I'll dig into it and report an issue if it turns out to be something else in iceberg-go.

Thanks again for the fix, @zeroshade ! 🙇

@kevinjqliu kevinjqliu left a comment

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.

LGTM!

Comment thread manifest.go

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.

I also checked WriteManifestList 👍

iceberg-go/manifest.go

Lines 1324 to 1352 in 43b308a

// WriteManifestList writes a list of manifest files to an avro file.
func WriteManifestList(version int, out io.Writer, snapshotID int64, parentSnapshotID, sequenceNumber *int64, files []ManifestFile) error {
var (
writer *ManifestListWriter
err error
)
switch version {
case 1:
writer, err = NewManifestListWriterV1(out, snapshotID, parentSnapshotID)
case 2:
if sequenceNumber == nil {
return errors.New("sequence number is required for V2 tables")
}
writer, err = NewManifestListWriterV2(out, snapshotID, *sequenceNumber, parentSnapshotID)
default:
return fmt.Errorf("unsupported manifest version: %d", version)
}
if err != nil {
return err
}
if err = writer.AddManifests(files); err != nil {
return err
}
return writer.Close()
}

@kevinjqliu

Copy link
Copy Markdown
Contributor

Thanks for chiming in everyone! Love the discussion here :)

@zeroshade
zeroshade merged commit 85f7008 into apache:main May 27, 2025
@zeroshade
zeroshade deleted the manifest-length-size branch May 27, 2025 16:03
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.

Manifest list written by go-iceberg contains incorrect file lengths

4 participants