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


##########
core/src/main/java/org/apache/iceberg/ManifestFilterManager.java:
##########
@@ -92,6 +93,9 @@ public String partition() {
   // cache filtered manifests to avoid extra work when commits fail.
   private final Map<ManifestFile, ManifestFile> filteredManifests = 
Maps.newConcurrentMap();
 
+  // the manifests that filteredManifests was filled from, by path, with the 
metadata they inherited
+  private final Map<String, ManifestFile> filteredSources = 
Maps.newConcurrentMap();

Review Comment:
   Thanks @amogh-jahagirdar @timothyw553, agreed, that's the right fix. Done in 
99c5a3a: a new package-private `ManifestCacheKey` (location, sequence number, 
first row ID) keys all three caches, `SnapshotProducer.manifestsWithMetadata`, 
`ManifestFilterManager.filteredManifests` and 
`ManifestMergeManager.mergedManifests`, and the extra `filteredSources` map is 
gone. `SnapshotProducer` keeps its loader as it was (a manifest with a snapshot 
ID is returned as is).
   
   One thing the keys alone don't cover: an entry that an earlier attempt 
cached under the old key would stay in the filter and merge caches until 
`cleanUncommitted`, and the manifests it replaced would be counted again in the 
snapshot summary's `manifests-replaced`, which `apply` builds before cleanup. 
So at the start of each attempt, `filterManifests` and `mergeManifests` drop 
the entries whose manifest is in the attempt's input under a different key, 
deleting the copy they wrote and correcting the count. That's a pass over the 
cache per attempt and no extra state; the merge manager keeps the replaced 
count with each merged manifest, since its key no longer carries the snapshot 
IDs that `cleanUncommitted` used to recount it.
   
   Keying the merge cache also fixes a case the first revision missed: a merge 
whose bin has only staged manifests, such as a delete with 
`commit.manifest.min-count-to-merge=2` after two fast appends in the 
transaction, reused the manifest merged in the first attempt. 
`retriedDeleteKeepsMetadataOfStagedManifestsItMerges` covers it and fails on 
main.



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