shivadarshan-devadiga commented on code in PR #19027:
URL: https://github.com/apache/iceberg/pull/19027#discussion_r4731559337


##########
core/src/main/java/org/apache/iceberg/BaseRewriteManifests.java:
##########
@@ -284,17 +295,39 @@ private boolean matchesPredicate(ManifestFile manifest) {
   }
 
   private void validateDeletedManifests(
-      Set<ManifestFile> currentManifests, long currentSnapshotID) {
-    // directly deleted manifests must be still present in the current snapshot
-    deletedManifests.stream()
-        .filter(manifest -> !currentManifests.contains(manifest))
-        .findAny()
-        .ifPresent(
-            manifest -> {
-              throw new ValidationException(
-                  "Deleted manifest %s could not be found in the latest 
snapshot %d",
-                  manifest.path(), currentSnapshotID);
-            });
+      Map<String, ManifestFile> currentManifestsByPath, long 
currentSnapshotID) {
+    for (ManifestFile manifest : deletedManifests) {
+      // directly deleted manifests must be still present in the current 
snapshot
+      ManifestFile current = currentManifestsByPath.get(manifest.path());
+      ValidationException.check(
+          current != null,
+          "Deleted manifest %s could not be found in the latest snapshot %d",
+          manifest.path(),
+          currentSnapshotID);
+
+      // a replacement written from the entries of a manifest that inherits 
other metadata now would
+      // not have it
+      ValidationException.check(
+          inheritsSameMetadata(manifest, current),

Review Comment:
   Thanks, I checked, and the `SnapshotProducer` cache does keep stale metadata 
on a retry, also without `RewriteManifests`: in a transaction with two fast 
appends, a concurrent commit makes it retry, and the second append's manifest 
list gets the first append's staged manifest from `manifestsWithMetadata` as it 
was in the first attempt. `FILE_A` then ends up with the concurrent commit's 
data sequence number (1 instead of 2) in v2, and in v3 and v4 also with its 
first row ID (0, which overlaps the concurrent commit's rows, instead of 1). As 
you say, `manifest` and `current` are then both stale and this check can't see 
it. Since it affects any transaction with more than one operation over a staged 
manifest, I've opened #19186 for it and the `ManifestFilterManager` cache, and 
have opened #19187 PR for it, so that this one stays about `RewriteManifests`.



-- 
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]

Reply via email to