This is an automated email from the ASF dual-hosted git repository.
blue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iceberg.git
The following commit(s) were added to refs/heads/master by this push:
new 6760b95 Hive: Ensure unlock is called when uncommitted metadata
delete fails (#1998)
6760b95 is described below
commit 6760b95e1997a3d43ce82f13e95944a7dda19d21
Author: Jack Ye <[email protected]>
AuthorDate: Mon Dec 28 10:42:46 2020 -0800
Hive: Ensure unlock is called when uncommitted metadata delete fails (#1998)
---
.../org/apache/iceberg/hive/HiveTableOperations.java | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git
a/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java
b/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java
index 0c99b4d..05ca375 100644
---
a/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java
+++
b/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java
@@ -207,11 +207,7 @@ public class HiveTableOperations extends
BaseMetastoreTableOperations {
throw new RuntimeException("Interrupted during commit", e);
} finally {
- if (threw) {
- // if anything went wrong, clean up the uncommitted metadata file
- io().deleteFile(newMetadataLocation);
- }
- unlock(lockId);
+ cleanupMetadataAndUnlock(threw, newMetadataLocation, lockId);
}
}
@@ -367,6 +363,20 @@ public class HiveTableOperations extends
BaseMetastoreTableOperations {
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;
+ } finally {
+ unlock(lockId);
+ }
+ }
+
private void unlock(Optional<Long> lockId) {
if (lockId.isPresent()) {
try {