Repository navigation
fix(spec): validate the metadata log in build() with the entry for the previous file - #3695
Conversation
laskoviymishka
left a comment
There was a problem hiding this comment.
Thanks @c-thiel for the repro test. As I read it, running try_normalize() after the push only changes the outcome of validate_chronological_metadata_logs, and the builds that now fail are the ones the deserializer already rejects on load. Java and iceberg-go also append the previous-file entry before the same one-minute check.
| } | ||
|
|
||
| #[test] | ||
| fn test_metadata_change_after_a_fast_branch_snapshot_is_refused_in_build() { |
There was a problem hiding this comment.
Could we add a companion case where the skew stays inside the one-minute tolerance (say 30s) and the second build() still succeeds? This test is the only one that reaches the metadata-log check with a previous-file entry, so nothing would catch the check being tightened past the tolerance.
There was a problem hiding this comment.
Added test_metadata_change_after_a_slightly_fast_branch_snapshot_builds in fa4c201: the same setup with 30 s of skew, where the second build() succeeds and the entry for the previous file is the last metadata-log entry. Both tests now share a small helper. With the tolerance cut to 10 s, the new test fails.
…skew tolerance builds
Which issue does this PR close?
A writer whose clock runs ahead can make
TableMetadataBuilderproduce table metadata that neither this crate nor Iceberg Java can load again.What changes are included in this PR?
TableMetadataBuilder::build()validated the new metadata before it added the metadata-log entry for the previous metadata file. A build whoselast-updated-mswas more than one minute before that entry passed. The written file then failed to load with "Invalid update timestamp …: before last metadata log entry".One way to get there: a writer whose clock is ahead adds a snapshot on a branch, so
last-updated-msbecomes that snapshot's time. The next change to the table that adds no snapshot takes the current time, which is before the previous file's entry.build()now adds the entry and expires the metadata log before it validates, so such a build fails instead of producing metadata that no reader can load. Iceberg Java (TableMetadata.Builder.build(), then theTableMetadataconstructor) and iceberg-go (MetadataBuilder.Build) check in this order.Are these changes tested?
Yes.
test_metadata_change_after_a_fast_branch_snapshot_is_refused_in_buildinspec::table_metadata_builderadds a branch snapshot dated two hours ahead, then sets a property, and checks that the build fails with the metadata-log error. It fails without the fix.AI Disclosure
Supported by Claude Code. Reviewed and checked by me.