BsoBird commented on code in PR #9546:
URL: https://github.com/apache/iceberg/pull/9546#discussion_r1506023627


##########
core/src/main/java/org/apache/iceberg/hadoop/HadoopTableOperations.java:
##########
@@ -368,58 +431,63 @@ private void renameToFinal(FileSystem fs, Path src, Path 
dst, int nextVersion) {
       if (fs.exists(dst)) {
         throw new CommitFailedException("Version %d already exists: %s", 
nextVersion, dst);
       }
-
-      if (!fs.rename(src, dst)) {
-        CommitFailedException cfe =
-            new CommitFailedException("Failed to commit changes using rename: 
%s", dst);
-        RuntimeException re = tryDelete(src);
-        if (re != null) {
-          cfe.addSuppressed(re);
-        }
-        throw cfe;
-      }
-    } catch (IOException e) {
-      CommitFailedException cfe =
-          new CommitFailedException(e, "Failed to commit changes using rename: 
%s", dst);
-      RuntimeException re = tryDelete(src);
-      if (re != null) {
-        cfe.addSuppressed(re);
+      if (!nextVersionIsLatest(nextVersion, fs)) {
+        throw new CommitFailedException("Version %d too old: %s", nextVersion, 
dst);

Review Comment:
   My intention in using the nextVersionIsLatest method is not to solve the 
problem of multiple clients committing the same version in parallel, which is 
ultimately guaranteed by the fs.rename method.
   
   The purpose of nextVersionIsLatest is to ensure that a client does not 
commit an older version that has been cleaned up. if an old version can commit 
success,it seems to be a violation of the convention.



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to