Skip to content

Commit

Permalink
Core: Throw CommitStateUnknownException if RuntimeException that is n…
Browse files Browse the repository at this point in the history
…ot marked as cleanable is thrown
  • Loading branch information
amogh-jahagirdar committed May 24, 2024
1 parent bd046f8 commit f9fb642
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/src/main/java/org/apache/iceberg/BaseTransaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ private void commitCreateTransaction() {
// the commit failed and no files were committed. clean up each update
if (!ops.requireStrictCleanup() || e instanceof CleanableFailure) {
cleanAllUpdates();
} else if (ops.requireStrictCleanup()) {
throw new CommitStateUnknownException(e);
}

throw e;
Expand Down Expand Up @@ -388,6 +390,8 @@ private void commitReplaceTransaction(boolean orCreate) {
// the commit failed and no files were committed. clean up each update.
if (!ops.requireStrictCleanup() || e instanceof CleanableFailure) {
cleanAllUpdates();
} else if (ops.requireStrictCleanup()) {
throw new CommitStateUnknownException(e);
}

throw e;
Expand Down Expand Up @@ -436,6 +440,8 @@ private void commitSimpleTransaction() {
} catch (RuntimeException e) {
if (!ops.requireStrictCleanup() || e instanceof CleanableFailure) {
cleanUpOnCommitFailure();
} else if (ops.requireStrictCleanup()) {
throw new CommitStateUnknownException(e);
}

throw e;
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/org/apache/iceberg/SnapshotProducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,8 @@ public void commit() {
} catch (RuntimeException e) {
if (!strictCleanup || e instanceof CleanableFailure) {
Exceptions.suppressAndThrow(e, this::cleanAll);
} else if (strictCleanup) {
throw new CommitStateUnknownException(e);
}

throw e;
Expand Down

0 comments on commit f9fb642

Please sign in to comment.