RussellSpitzer commented on a change in pull request #2328:
URL: https://github.com/apache/iceberg/pull/2328#discussion_r599127928
##########
File path:
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java
##########
@@ -222,11 +252,51 @@ protected void doCommit(TableMetadata base, TableMetadata
metadata) {
throw new RuntimeException("Interrupted during commit", e);
} finally {
- cleanupMetadataAndUnlock(threw, newMetadataLocation, lockId);
+ cleanupMetadataAndUnlock(commitStatus, newMetadataLocation, lockId);
+ }
+ }
+
+ /**
+ * Attempt to load the table and see if any current or past metadata
location matches the one we were attempting
+ * to set. This is used as a last resort when we are dealing with exceptions
that may indicate the commit has
+ * failed but are not proof that this is the case. Past locations must also
be searched on the chance that a second
+ * committer was able to successfully commit on top of our commit.
+ *
+ * @param newMetadataLocation the path of the new commit file
+ * @param config metadata to use for configuration
+ * @return Commit Status of Success, Failure or Unknown
+ */
+ private CommitStatus checkCommitStatus(String newMetadataLocation,
TableMetadata config) {
+ int maxAttempts = PropertyUtil.propertyAsInt(config.properties(),
COMMIT_NUM_STATUS_CHECKS,
+ COMMIT_NUM_STATUS_CHECKS_DEFAULT);
+
+ for (int attempt = 1; attempt <= maxAttempts; attempt++) {
Review comment:
I considered this but I didn't like how I have to set the return value
inside of the lambda and can't return from there. I also can't count the number
of attempts without another counter, maybe that's a good addition for the task
API an "onFailure(item, Exception, Attempt)"
--
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]