shivadarshan-devadiga opened a new pull request, #19187: URL: https://github.com/apache/iceberg/pull/19187
Closes #19186. When a transaction retries after a concurrent commit, a manifest that an earlier operation in the transaction staged keeps its path, and gets a new sequence number and first row ID in the new manifest list. A later operation still used it as it was in the first attempt, because `SnapshotProducer.manifestsWithMetadata` and `ManifestFilterManager.filteredManifests` are keyed by `ManifestFile`, which compares by path. The transaction then committed the staged manifest's files with the first attempt's data sequence number, and in v3+ with first row IDs that overlap the concurrent commit's. This PR: - `SnapshotProducer`: a manifest that already has a snapshot ID has its metadata from the manifest list it was read from, so it is no longer looked up in `manifestsWithMetadata`, which the loader already returned as is. The cache now only adds metadata to new manifests. - `ManifestFilterManager`: remembers the manifest each cache entry was filtered from. When a manifest with the same path inherits other metadata (sequence number, min sequence number or first row ID), the entry is evicted, deleting the filtered copy if one was written, and the manifest is filtered again. A committed manifest never changes these values, so only staged manifests of a retried transaction are filtered again. A merging append already kept the metadata of the staged manifest; its test passes without this change too. ## Testing New tests in `TestTransaction`, for format versions 2 and 3, check that FILE_A, staged by the transaction's first operation, keeps the data sequence number and first row ID of that snapshot after a concurrent commit makes the transaction retry: - `retriedFastAppendKeepsMetadataOfStagedManifest`: a second fast append. - `retriedDeleteKeepsMetadataOfStagedManifest`: a delete that keeps the staged manifest. - `retriedDeleteKeepsMetadataOfStagedManifestItRewrites`: a delete that rewrites the staged manifest. - `retriedMergeAppendKeepsMetadataOfStagedManifest`: a merging append, which already passed. Without this change, the first three fail with `expected: 2L but was: 1L` on format versions 2 and 3. With it, they pass, and so does the rest of `iceberg-core`, including `TestTransaction`, `TestFastAppend`, `TestMergeAppend`, `TestDeleteFiles`, `TestOverwrite`, `TestRowDelta`, `TestRewriteFiles`, `TestRewriteManifests`, `TestReplacePartitions`, `TestRowLineageMetadata`, `TestSequenceNumberForV2Table` and `TestSnapshotProducer`. (I ran it on IBM Semeru 21, where four unrelated tests that check HotSpot exception messages or GC-dependent caching fail on main too.) `spotlessCheck`, `checkstyleMain` and `checkstyleTest` pass. ## Was this patch authored or co-authored using generative AI tooling? Co-authored by: Claude Sonnet 4.5 -- 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]
