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


##########
core/src/main/java/org/apache/iceberg/hadoop/HadoopTableOperations.java:
##########
@@ -157,18 +158,37 @@ public void commit(TableMetadata base, TableMetadata 
metadata) {
     int nextVersion = (current.first() != null ? current.first() : 0) + 1;
     Path finalMetadataFile = metadataFilePath(nextVersion, codec);
     FileSystem fs = getFileSystem(tempMetadataFile, conf);
-
-    // this rename operation is the atomic commit operation
-    renameToFinal(fs, tempMetadataFile, finalMetadataFile, nextVersion);
-
-    LOG.info("Committed a new metadata file {}", finalMetadataFile);
-
-    // update the best-effort version pointer
-    writeVersionHint(nextVersion);
-
-    deleteRemovedMetadataFiles(base, metadata);
-
-    this.shouldRefresh = true;
+    boolean versionCommitSuccess = false;
+    try {
+      deleteOldVersionHint(fs, versionHintFile(), nextVersion);
+      versionCommitSuccess = commitNewVersion(fs, tempMetadataFile, 
finalMetadataFile, nextVersion);
+      if (!versionCommitSuccess) {
+        String msg =
+            String.format(
+                "Can not write newMetaData. commitVersion = %s.Are there other 
clients running in parallel with the current task?",
+                nextVersion);
+        throw new RuntimeException(msg);
+      }
+      this.shouldRefresh = versionCommitSuccess;
+      LOG.info("Committed a new metadata file {}", finalMetadataFile);
+      // update the best-effort version pointer
+      writeVersionHint(fs, nextVersion);
+      deleteRemovedMetadataFiles(base, metadata);
+    } catch (CommitStateUnknownException | CommitFailedException e) {
+      this.shouldRefresh = e instanceof CommitStateUnknownException || 
versionCommitSuccess;
+      throw e;
+    } catch (Throwable e) {
+      this.shouldRefresh = versionCommitSuccess;
+      if (versionCommitSuccess) {
+        LOG.warn(

Review Comment:
   This is going to be extremely confusing. What should a user do when they see 
this message?



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