timothyw553 commented on code in PR #18821:
URL: https://github.com/apache/iceberg/pull/18821#discussion_r4722309989
##########
core/src/main/java/org/apache/iceberg/ManifestFilterManager.java:
##########
@@ -225,6 +225,8 @@ List<ManifestFile> filterManifests(Schema tableSchema,
List<ManifestFile> manife
filtered[index] = manifest;
});
+ deleteFiles.addAll(deletedFiles(filtered));
Review Comment:
since `deleteFiles` is now updated after all manifests finish, what happens
when one manifest has duplicate entries with different stats, like `[F with
id=1 stats, F without stats]`? to my understanding deleting `id=1` used to
succeed here, and now throws `Cannot delete file where some, but not all, rows
match`. should we check `deletedFiles` locally too (maybe on main first so the
backport stays in sync)?
```diff
boolean markedForDelete =
isDanglingDV
|| deletePaths.contains(file.location())
|| deleteFiles.contains(file)
+ || deletedFiles.contains(file)
|| dropPartitions.contains(file.specId(), file.partition())
```
##########
core/src/test/java/org/apache/iceberg/TestSnapshotSummary.java:
##########
@@ -200,6 +204,49 @@ public void deleteWithDuplicates() {
.containsEntry(SnapshotSummary.TOTAL_RECORDS_PROP, "0");
}
+ @TestTemplate
+ public void deleteDuplicateFilesWithConcurrentDeleteRetry() throws Exception
{
+ String tableName = "retry-duplicate-delete";
+ File retryTableDir = temp.resolve(tableName).toFile();
+ AtomicBoolean failCommitAfterConcurrentDelete = new AtomicBoolean(false);
+ TestTables.TestTableOperations ops =
+ new TestTables.TestTableOperations(tableName, retryTableDir) {
+ @Override
+ public void commit(TableMetadata base, TableMetadata
updatedMetadata) {
+ if (base != null &&
failCommitAfterConcurrentDelete.compareAndSet(true, false)) {
+ TestTables.load(retryTableDir, tableName)
+ .newDelete()
+ .deleteFromRowFilter(Expressions.alwaysTrue())
+ .commit();
+ throw new CommitFailedException("Injected concurrent delete");
+ }
+
+ super.commit(base, updatedMetadata);
+ }
+ };
+ this.table =
+ TestTables.create(
+ retryTableDir, tableName, SCHEMA, SPEC, SortOrder.unsorted(),
formatVersion, ops);
+ table.updateProperties().set("random-snapshot-ids", "true").commit();
+
+ DataFile file =
+ DataFiles.builder(SPEC)
+ .withPath("/path/to/concurrent-delete-duplicate.parquet")
+ .withFileSizeInBytes(10)
+ .withPartitionPath("data_bucket=0")
+ .withRecordCount(1)
+ .build();
+ ManifestFile manifest =
writeManifestWithName("concurrent-delete-duplicate", file, file);
+ table.newFastAppend().appendManifest(manifest).commit();
+
+ failCommitAfterConcurrentDelete.set(true);
+ table.newDelete().deleteFromRowFilter(Expressions.alwaysTrue()).commit();
+
+ assertThat(table.currentSnapshot().summary())
Review Comment:
this only asserts that the retry snapshot has no delete counts, so removing
the duplicate increment or storing `0` would still pass. could we also check
`deleted-duplicate-files` on the parent snapshot, and add a multi-manifest case
to cover aggregating counts across manifests?
```diff
+ Snapshot retrySnapshot = table.currentSnapshot();
+ assertThat(table.snapshot(retrySnapshot.parentId()).summary())
+ .containsEntry(SnapshotSummary.DELETED_DUPLICATE_FILES, "1");
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]