snicholasbarton commented on code in PR #19067:
URL: https://github.com/apache/iceberg/pull/19067#discussion_r4682956723


##########
core/src/main/java/org/apache/iceberg/SnapshotProducer.java:
##########
@@ -552,11 +552,16 @@ public void commit() {
       try {
         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.
+        // at this point, the commit must have succeeded. the snapshot is 
loaded by id in case
+        // another commit was added after this one, and the table is refreshed 
only if the current
+        // metadata does not contain it.
         // it might not be known which commit attempt succeeded in some cases, 
so this only cleans
         // up the one that actually did succeed.
-        Snapshot saved = ops.refresh().snapshot(newSnapshotId.get());
+        Snapshot saved = ops.current().snapshot(newSnapshotId.get());
+        if (saved == null) {
+          saved = ops.refresh().snapshot(newSnapshotId.get());

Review Comment:
   Have added your suggested test shape



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