Skip to content

fix(spec): mark stale snapshot errors in add_snapshot as retryable conflicts - #17

Merged
c-thiel merged 1 commit into
lakekeeper-compaction-basefrom
ct/stale-snapshot-retryable
Nov 2, 2026
Merged

c-thiel merged 1 commit into
lakekeeper-compaction-basefrom
ct/stale-snapshot-retryable

Conversation

@c-thiel

@c-thiel c-thiel commented Nov 2, 2026

Copy link
Copy Markdown
Member

A rewrite can now remove delete files. The rewrite commit check now refuses a commit only for new deletes that apply to the replaced files. Four fixes make rewrites and scans handle partitions correctly after schema and spec changes. Review commit by commit.

Commits

  • Let a rewrite remove delete files. New RewriteFilesAction::delete_delete_file removes a position delete file, an equality delete file or a deletion vector, as Java's RewriteFiles.deleteFile(DeleteFile) does. A rewrite that only removes delete files commits a replace snapshot. Delete files are matched by path, content offset and content size, so removing one deletion vector keeps the other vectors in the same Puffin file. A delete file given to delete_file, or a data file given to delete_delete_file, is refused with an error that names the right method. Known limitation for format v3: a removed deletion vector is counted in the summary as a position delete file with its Puffin file size. Java counts it under removed-dvs with its blob size. The action comes from feat(transaction): add MergingSnapshotProducer and RewriteFilesAction apache/iceberg-rust#3046 (open); upstream needs delete-only rewrites there first.
  • Reject a rewrite only for new deletes that apply to the replaced files. The check refused a commit when any delete manifest was added anywhere in the table after the starting snapshot. With a streaming writer that commits deletes every minute, almost every long compaction failed. The check now follows Java's validateNoNewDeletesForDataFiles. It refuses only for a new position delete or deletion vector that names a replaced file, or a new partition-scoped delete in the partition of a replaced file. Equality deletes newer than data_sequence_number are skipped when they still apply to the added files. Unlike Java, the check does not prune by column bounds. The rewrite is now always refused when its starting snapshot is not an ancestor of the current snapshot, as in Java.
  • Cherry-pick of fix(expr): widen promoted partition values and bounds to prevent false pruning apache/iceberg-rust#3483 (merged), author Anoop Johnson. Widens partition values and column bounds written before an int to long or float to double promotion. Without it, filtered scans pruned matching files, and deletes did not match data files from before the promotion. A conflict in data_file.rs was resolved by keeping both sides.
  • Rewrite a filtered manifest with the schema it was written with. Removing a file from a manifest written before a partition source promotion, or before its partition source column was dropped, panicked or was refused. Compaction of such a partition never committed. The filter now writes the manifest with its own schema, as row_delta and overwrite already do. Readers widen the values since fix(expr): widen promoted partition values and bounds to prevent false pruning apache/iceberg-rust#3483.
  • Apply equality deletes written under a void-only partition spec as global deletes. A table that dropped a partition field on format v1 keeps it as a void transform. Equality deletes written under that spec were applied only to files of the same spec, so the reader showed deleted rows and a rewrite wrote them back. The delete index now uses PartitionSpec::is_unpartitioned(), as Java does. This follows fix(scan): apply equality deletes from an all-void partition spec globally apache/iceberg-rust#3449 (open) line for line, with JeonDaehong as co-author. One extra test checks that an identity spec with a null value stays partition-scoped.
  • Fill absent identity partition columns before probing equality deletes. Files added from Hive tables often do not store the identity partition column. The equality-delete probe read that column as null, so deletes on it never applied. The probe now uses the file's identity partition value, as Java does. Related: perf(deletes): apply equality deletes via a hashed key set inside the parquet RowFilter apache/iceberg-rust#2961 (the hash-set probe, open) and fix(arrow): evaluate filters on columns missing from a data file against their identity partition value or initial-default apache/iceberg-rust#3302 (the predicate path only, open). The initial-default case (Equality deletes ignore spec projection rules for dropped and newly added delete columns apache/iceberg-rust#3369) is not included.

Tests

Each commit builds and passes cargo test -p iceberg --all-features --lib. For each fix, the main tests fail without it. New tests:

  • removing delete files: test_rewrite_files_removes_a_position_delete_file, ..._removes_an_equality_delete_file, ..._removes_one_deletion_vector_of_a_puffin_file, ..._refuses_invalid_delete_file_removals, ..._missing_delete_file, test_validate_duplicate_files_without_added_files_reads_no_manifest;
  • conflict check: test_rewrite_files_rejects_only_new_deletes_for_replaced_files (a table of 14 cases), ..._ignores_delete_manifests_rewritten_since_the_start, ..._rejects_new_deletes_in_rewritten_delete_manifests, ..._rejects_starting_snapshot_off_the_branch, test_may_be_same_partition;
  • manifest schema: test_rewrite_files_rewrites_a_manifest_written_before_a_promotion, test_rewrite_files_after_dropping_an_old_partition_source;
  • void-only spec: test_void_spec_equality_delete_is_global, test_identity_spec_null_partition_equality_delete_stays_scoped;
  • absent partition column: test_eq_delete_on_identity_partition_column_absent_from_data_file, test_eq_delete_on_uuid_partition_column_absent_from_data_file, test_eq_delete_on_absent_partition_column_with_unwidened_value.

The cherry-pick brings its upstream tests.

Compatibility

  • New public method RewriteFilesAction::delete_delete_file. No public item is removed or changed.
  • Rewrites that the old check refused now commit when the new deletes do not apply to the replaced files.
  • A rewrite whose starting snapshot is not an ancestor of the current snapshot is now refused, also without new deletes.
  • The error text for a conflicting delete changed. It now names the delete file and the replaced data file. Callers that match on the old text must be updated.
  • The manifest format does not change.

…nflicts

A snapshot whose sequence number is not above the table's last sequence number (format version 2 and later, with a parent), or whose first-row-id is behind the table's next-row-id (format version 3), was built on outdated table metadata: another commit, for example on another branch, advanced the table-wide counters. A reload and a new attempt commits. Both errors are now ErrorKind::CatalogCommitConflicts with retryable set, as requirement failures already are, so a catalog can answer them with 409 and Transaction::commit retries them. This mirrors Iceberg Java's RetryableValidationException (apache/iceberg#15126, Java 1.11). All other add_snapshot errors stay DataInvalid; an existing snapshot id is checked first, so a resend of a landed snapshot is not retried.
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