Skip to content

Scope concurrent delete-file conflicts by partition - #4508

Open
harshilv17 wants to merge 1 commit into
apache:mainfrom
harshilv17:fix/scope-delete-file-conflicts-by-partition
Open

harshilv17 wants to merge 1 commit into
apache:mainfrom
harshilv17:fix/scope-delete-file-conflicts-by-partition

Conversation

@harshilv17

Copy link
Copy Markdown

Closes #4507

Rationale for this change

On a commit retry, _validate_no_new_delete_files is called with partition_set=None, and _added_delete_files can only rule out a delete file by its column stats. Position deletes and deletion vectors have no stats on data columns, so a delete file committed concurrently in any partition fails a partition-filtered delete() or overwrite(). This shows up on tables shared with Spark or Flink merge-on-read writers. It was raised in the #3320 review and deferred with a code comment.

Java scopes this by partition: DeleteFileIndex.Builder projects the data filter onto each spec with Projections.inclusive(spec, caseSensitive) and filters delete manifest entries by partition. This change does the same in _added_delete_files: when a data_filter is given, it builds a per-spec evaluator from inclusive_projection + expression_evaluator (as DataScan._build_partition_evaluator does) and skips delete files whose partition can't match. A filter on non-partition columns projects to AlwaysTrue, so those delete files still count as conflicts. The comment deferring this in snapshot.py is removed.

Are these changes tested?

Yes. test_partition_filtered_write_validates_concurrent_position_delete_by_partition in tests/table/test_commit_retry.py commits a concurrent position delete (with the existing commit_partition_position_delete helper) in the written partition and in another one, for both delete and overwrite, on each catalog fixture. On main the other-partition cases fail with ValidationException: Found new conflicting delete files; with this change they succeed, and the same-partition cases still conflict.

test_added_delete_files_case_insensitive_filter used a mock delete file with partition=None on a table partitioned by x, which a real manifest can't contain; it now has partition=Record(1).

tests/table passes, and ruff and mypy are clean.

Are there any user-facing changes?

Yes: a delete() or overwrite() filtered to some partitions no longer fails its commit retry because another writer committed a delete file in an unrelated partition.

Commit validation checked concurrent delete files only against the data
filter's column metrics, which position deletes and deletion vectors
don't have for data columns, so any delete file committed in another
partition failed a partition-filtered delete or overwrite. Project the
data filter onto each delete file's spec, as Java's DeleteFileIndex
does, and skip delete files whose partition can't match.

This branch has not been deployed

No deployments
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.

Commit retry rejects a partition-filtered delete/overwrite when a concurrent position delete lands in a different partition

1 participant