nastra commented on code in PR #15511:
URL: https://github.com/apache/iceberg/pull/15511#discussion_r2939007765
##########
core/src/main/java/org/apache/iceberg/SnapshotProducer.java:
##########
@@ -509,22 +509,27 @@ public void commit() {
throw e;
}
- // at this point, the commit must have succeeded so the stagedSnapshot
is committed
- Snapshot committedSnapshot = stagedSnapshot.get();
try {
- LOG.info(
- "Committed snapshot {} ({})",
- committedSnapshot.snapshotId(),
- getClass().getSimpleName());
+ LOG.info("Committed snapshot {} ({})", newSnapshotId.get(),
getClass().getSimpleName());
+
+ // at this point, the commit must have succeeded. after a refresh, the
snapshot is loaded by
+ // id in case another commit was added between this commit and the
refresh.
+ Snapshot saved = ops.refresh().snapshot(newSnapshotId.get());
+ if (saved != null) {
+ if (cleanupAfterCommit()) {
+ cleanUncommitted(Sets.newHashSet(saved.allManifests(ops.io())));
+ }
- if (cleanupAfterCommit()) {
-
cleanUncommitted(Sets.newHashSet(committedSnapshot.allManifests(ops.io())));
- }
- // also clean up unused manifest lists created by multiple attempts
- for (String manifestList : manifestLists) {
- if (!committedSnapshot.manifestListLocation().equals(manifestList)) {
- deleteFile(manifestList);
+ // also clean up unused manifest lists created by multiple attempts
+ for (String manifestList : manifestLists) {
+ if (!saved.manifestListLocation().equals(manifestList)) {
+ deleteFile(manifestList);
+ }
}
+ } else {
+ // saved may not be present if the latest metadata couldn't be
loaded due to eventual
+ // consistency problems in refresh. in that case, don't clean up.
Review Comment:
this is really just restoring the behavior + wording to how it was prior to
https://github.com/apache/iceberg/commit/39373d09c276586ddcec971fe35951975bdac66f
so I didn't do any other modifications to the code other than adding a test.
The wording itself here was added a few years ago by
https://github.com/apache/iceberg/commit/5300d27cc6e6f681e2e499ce5ee4269afe22394a
and the commit details mention that no exception should be thrown
--
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]