shivadarshan-devadiga commented on code in PR #19027:
URL: https://github.com/apache/iceberg/pull/19027#discussion_r4735101521
##########
core/src/main/java/org/apache/iceberg/BaseRewriteManifests.java:
##########
@@ -284,17 +295,45 @@ 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, good point, that's better. Done in
[9ff3065](https://github.com/apache/iceberg/pull/19027/changes/9ff30650f43007e565e873a8c36ec4b3722ab3dd):
`validateDeletedManifests` now keeps each deleted manifest as the first
attempt found it in the current snapshot, by path, and on every attempt
compares the current manifest with that one instead of with the `ManifestFile`
the caller passed. So the check no longer depends on the caller's object having
its metadata: the skip for a sequence number of -1 or a NULL first row ID that
I added for @timothyw553's comment is gone, and `inheritsSameMetadata` compares
all three values again.
The new test `replaceWrittenManifestAfterTransactionRetry` covers the case
you describe: it appends the manifest that `ManifestWriter.toManifestFile()`
returns in a transaction, replaces it through that object, and a concurrent
commit makes the transaction retry. Without the change, the commit succeeds
with the stale metadata; with it, it fails with `Deleted manifest ... changed
in the latest snapshot`. `deleteManifestWrittenButNotReadFromSnapshot`, which
deletes such a manifest without a retry, still passes, and so does the rest of
`TestRewriteManifests`.
--
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]