Skip to content

fix(overwrite): address 5 correctness issues from post-merge review#77

Merged
gbrgr merged 1 commit into
mainfrom
gb/overwrite-fixes
May 28, 2026
Merged

fix(overwrite): address 5 correctness issues from post-merge review#77
gbrgr merged 1 commit into
mainfrom
gb/overwrite-fixes

Conversation

@gbrgr
Copy link
Copy Markdown
Collaborator

@gbrgr gbrgr commented May 28, 2026

Summary

Addresses 5 correctness issues flagged in the post-merge review of #76.

  • Fix 1 (snapshot.rs): previous_snapshot lookup used self.snapshot_id (the new, uncommitted snapshot — never in the metadata), so it always resolved to None. Changed to table_metadata.current_snapshot(). This fixes a latent u64 underflow when a delete-only overwrite has a net-negative file count.

  • Fix 2 (overwrite.rs): rewrite_manifest always used default_partition_spec() when writing the rewritten manifest. Now looks up partition_spec_by_id(manifest_file.partition_spec_id), returning DataInvalid if missing. Prevents partition-metadata corruption on spec-evolved tables.

  • Fix 3 (overwrite.rs): A delete-only overwrite on a table with no current snapshot silently produced a misleading snapshot. Now returns PreconditionFailed upfront.

  • Fix 4 (overwrite.rs): existing_manifest dropped delete-only manifests in both filter paths, while FastAppendOperation was just widened (in feat(transaction): add OverwriteAction with CoW delete support #76) to preserve them. Added has_deleted_files() to both paths for consistency and to preserve time-travel auditability across overwrite chains.

  • Fix 5 (overwrite.rs): Added two tests: test_overwrite_unaffected_manifest_passthrough (exercises the passthrough branch for manifests with no matching deletes) and test_delete_only_overwrite_summary (regresses Fix 1 — would panic with u64 underflow without it).

Test plan

  • cargo test -p iceberg --lib transaction::overwrite::tests — all 7 tests pass
  • cargo test -p iceberg --lib transaction:: — all 26 transaction tests pass

🤖 Generated with Claude Code

…view

1. snapshot.rs: fix `previous_snapshot` lookup — `self.snapshot_id` is the
   new (uncommitted) snapshot and is never in the metadata; use
   `current_snapshot()` instead to correctly compute the previous totals
   for `update_snapshot_summaries`. This fixes a latent u64 underflow when
   a delete-only overwrite results in a net-negative file count.

2. overwrite.rs: `rewrite_manifest` now looks up the partition spec from
   `manifest_file.partition_spec_id` instead of always using the default
   spec, preventing partition-metadata corruption on spec-evolved tables.

3. overwrite.rs: guard against delete-only overwrite on a table with no
   current snapshot — return `PreconditionFailed` instead of silently
   producing a misleading snapshot.

4. overwrite.rs: `existing_manifest` now preserves delete-only manifests
   (`has_deleted_files()`) in both filter paths, matching the behavior of
   `FastAppendOperation` and maintaining time-travel auditability.

5. Two new tests: `test_overwrite_unaffected_manifest_passthrough` covers
   the passthrough branch (manifest with no matching deletes), and
   `test_delete_only_overwrite_summary` covers correct summary computation
   for a delete-only overwrite (regresses the u64 fix in point 1).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gbrgr gbrgr merged commit 27f68f7 into main May 28, 2026
16 of 19 checks passed
@gbrgr gbrgr deleted the gb/overwrite-fixes branch May 28, 2026 14:34
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.

1 participant