You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2020/12/29 11:34:58 UTC

[GitHub] [iceberg] aokolnychyi commented on a change in pull request #1998: Hive: ensure unlock is called when new metadata cannot be deleted

aokolnychyi commented on a change in pull request #1998:
URL: https://github.com/apache/iceberg/pull/1998#discussion_r549671840



##########
File path: hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java
##########
@@ -367,6 +363,20 @@ private long acquireLock() throws UnknownHostException, TException, InterruptedE
     return lockId;
   }
 
+  private void cleanupMetadataAndUnlock(boolean errorThrown, String metadataLocation, Optional<Long> lockId) {
+    try {
+      if (errorThrown) {
+        // if anything went wrong, clean up the uncommitted metadata file
+        io().deleteFile(metadataLocation);
+      }
+    } catch (RuntimeException e) {
+      LOG.error("Fail to cleanup metadata file at {}", metadataLocation, e);
+      throw e;

Review comment:
       I think we may leverage `runSafely` that was added recently.
   
   ```
       ExceptionUtil.runSafely(
           () -> {
             if (errorThrown) {
               // if anything went wrong, clean up the uncommitted metadata file
               io().deleteFile(metadataLocation);
             }
             return Void.TYPE;
           },
           e -> LOG.error("Failed to cleanup metadata file at {}", metadataLocation, e),
           () -> unlock(lockId));
   ```
   




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

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



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