Skip to content

Commit

Permalink
Changed test in FastAppend to testy retry with transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonf20 committed Dec 6, 2023
1 parent 47d8f54 commit aa9bee7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/apache/iceberg/FastAppend.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ protected void cleanUncommitted(Set<ManifestFile> committed) {
deleteFile(manifest.path());
}
}
this.newManifests = null;
this.newManifests = committedNewManifests;
}

// clean up only rewrittenAppendManifests as they are always owned by the table
Expand Down
26 changes: 13 additions & 13 deletions core/src/test/java/org/apache/iceberg/TestFastAppend.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,34 +314,34 @@ public void testRecoveryWithoutManifestList() {
}

@Test
public void testRecoveryWithManualReCommit() {
public void testRecoveryWithTransaction() {
TestTables.TestTableOperations ops = table.ops();
ops.failCommits(5);

AppendFiles append = table.newFastAppend().appendFile(FILE_B);
Transaction transaction = table.newTransaction();
AppendFiles append = transaction.newFastAppend().appendFile(FILE_B);

Snapshot pending = append.apply();
ManifestFile newManifest = pending.allManifests(FILE_IO).get(0);
Assert.assertTrue("Should create new manifest", new File(newManifest.path()).exists());
ManifestFile originalManifest = pending.allManifests(FILE_IO).get(0);
append.commit();

Assertions.assertThatThrownBy(append::commit)
Assertions.assertThatThrownBy(transaction::commitTransaction)
.isInstanceOf(CommitFailedException.class)
.hasMessage("Injected failure");

TableMetadata metadata = readMetadata();

Assert.assertNull("No snapshot is committed", metadata.currentSnapshot());

pending = append.apply();
newManifest = pending.allManifests(FILE_IO).get(0);

append.commit();
transaction.commitTransaction();

metadata = readMetadata();
validateSnapshot(null, metadata.currentSnapshot(), FILE_B);
Assert.assertTrue("Should commit same new manifest", new File(newManifest.path()).exists());
Assert.assertTrue(
"Should commit the same new manifest",
metadata.currentSnapshot().allManifests(FILE_IO).contains(newManifest));
"Original manifest from before retry should exist",
new File(originalManifest.path()).exists());
Assert.assertTrue(
"Should commit the original manifest created before retrying the transaction",
metadata.currentSnapshot().allManifests(FILE_IO).contains(originalManifest));
}

@Test
Expand Down

0 comments on commit aa9bee7

Please sign in to comment.