This is an automated email from the ASF dual-hosted git repository.
etudenhoefner 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 e12ea75747 Nessie: Fix possible table-metadata loss (#8413)
e12ea75747 is described below
commit e12ea75747baf2fc700049d8e59ec4d4a42444ae
Author: Robert Stupp <[email protected]>
AuthorDate: Tue Aug 29 18:58:20 2023 +0200
Nessie: Fix possible table-metadata loss (#8413)
`NessieTableOperations.doCommit()` wrongly assumes that _every_ exception
thrown during a Nessie commit operation is a failure that requires the deletion
of the newly written table-metadata. However, for exceptions like
`j.l.InterruptedException` or HTTP timeout/error it is unclear whether the
Nessie commit went through (or will go through), so deleting the table-metadata
is wrong here.
This change updates the logic to only delete the table-metadata file if a
`NessieReferenceConflictException` happened, when it is clear that the commit
really failed.
---
.../java/org/apache/iceberg/nessie/NessieTableOperations.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git
a/nessie/src/main/java/org/apache/iceberg/nessie/NessieTableOperations.java
b/nessie/src/main/java/org/apache/iceberg/nessie/NessieTableOperations.java
index 863f90b3b5..4a55c73ec4 100644
--- a/nessie/src/main/java/org/apache/iceberg/nessie/NessieTableOperations.java
+++ b/nessie/src/main/java/org/apache/iceberg/nessie/NessieTableOperations.java
@@ -134,11 +134,11 @@ public class NessieTableOperations extends
BaseMetastoreTableOperations {
String newMetadataLocation = writeNewMetadataIfRequired(newTable,
metadata);
String refName = client.refName();
- boolean delete = true;
+ boolean failure = false;
try {
client.commitTable(base, metadata, newMetadataLocation, table, key);
- delete = false;
} catch (NessieConflictException ex) {
+ failure = true;
if (ex instanceof NessieReferenceConflictException) {
// Throws a specialized exception, if possible
maybeThrowSpecializedException((NessieReferenceConflictException) ex);
@@ -153,13 +153,13 @@ public class NessieTableOperations extends
BaseMetastoreTableOperations {
// to catch all kinds of network errors (e.g. connection reset). Network
code implementation
// details and all kinds of network devices can induce unexpected
behavior. So better be
// safe than sorry.
- delete = false;
throw new CommitStateUnknownException(ex);
} catch (NessieNotFoundException ex) {
+ failure = true;
throw new RuntimeException(
String.format("Cannot commit: Reference '%s' no longer exists",
refName), ex);
} finally {
- if (delete) {
+ if (failure) {
io().deleteFile(newMetadataLocation);
}
}