Repository navigation
Scope concurrent delete-file conflicts by partition - #4508
harshilv17 wants to merge 2 commits into
Conversation
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.
|
@lawofcycles could you take a look? This scopes the delete-file conflict check by partition, the follow-up deferred in #3320 (#3320 (comment)). |
|
@Fokko @kevinjqliu could one of you take a look when you have time? This scopes the concurrent delete-file conflict check by partition, the follow-up deferred in #3320. I have a stacked follow-up ready that also prunes manifests during validation. |
rahulsmahadev
left a comment
There was a problem hiding this comment.
Thanks @harshilv17! This matches Java's DeleteFileIndex, and the new test fails on main and passes here. In 512 cases with real concurrent commits (identity, bucket, truncate and time transforms, null partitions, older and newly added specs, unpartitioned deletes), every concurrent delete of a row matching the filter still conflicted. LGTM.
A couple of smaller suggestions are inline, plus the changelog label, since users can see this.
|
|
||
| dfi = DeleteFileIndex() | ||
|
|
||
| # Delete files have no stats on the data columns, so only the partition can rule them out: |
There was a problem hiding this comment.
Nit: equality deletes have stats on their equality columns, and position deletes have data-column stats when they store the deleted row, so the stats check below can still rule some out. Maybe "Position deletes and deletion vectors usually have no stats on the data columns, so also prune by partition: ...".
| row_filter = data_filter | ||
|
|
||
| def _partition_evaluator(spec_id: int) -> Callable[[Record], bool]: | ||
| spec = table.specs()[spec_id] |
There was a problem hiding this comment.
Nothing covers a delete file written under an older spec: with table.spec() here, tests/table still passes. A test that changes the spec (say identity on category to bucket on value) and then commits a delete under the old spec in another partition would pin it.
Cover a concurrent delete file written under a spec that is no longer current, so validation must project the filter onto that file's spec. Clarify the comment on why delete files are pruned by partition.
|
Thanks @rahulsmahadev! Reworded the comment as suggested, and added |
Closes #4507
Rationale for this change
On a commit retry,
_validate_no_new_delete_filesis called withpartition_set=None, and_added_delete_filescan 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-filtereddelete()oroverwrite(). 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.Builderprojects the data filter onto each spec withProjections.inclusive(spec, caseSensitive)and filters delete manifest entries by partition. This change does the same in_added_delete_files: when adata_filteris given, it builds a per-spec evaluator frominclusive_projection+expression_evaluator(asDataScan._build_partition_evaluatordoes) and skips delete files whose partition can't match. A filter on non-partition columns projects toAlwaysTrue, so those delete files still count as conflicts. The comment deferring this insnapshot.pyis removed.Are these changes tested?
Yes.
test_partition_filtered_write_validates_concurrent_position_delete_by_partitionintests/table/test_commit_retry.pycommits a concurrent position delete (with the existingcommit_partition_position_deletehelper) in the written partition and in another one, for bothdeleteandoverwrite, on each catalog fixture. On main the other-partition cases fail withValidationException: Found new conflicting delete files; with this change they succeed, and the same-partition cases still conflict.test_added_delete_files_case_insensitive_filterused a mock delete file withpartition=Noneon a table partitioned byx, which a real manifest can't contain; it now haspartition=Record(1).tests/tablepasses, and ruff and mypy are clean.Are there any user-facing changes?
Yes: a
delete()oroverwrite()filtered to some partitions no longer fails its commit retry because another writer committed a delete file in an unrelated partition.