BsoBird commented on code in PR #9546: URL: https://github.com/apache/iceberg/pull/9546#discussion_r1651072649
########## core/src/test/java/org/apache/iceberg/hadoop/TestHadoopCommits.java: ########## @@ -206,6 +210,139 @@ public void testFailedCommit() throws Exception { Assertions.assertThat(manifests).as("Should contain 0 Avro manifest files").isEmpty(); } + @Test + public void testCommitFailedBeforeChangeVersionHint() throws IOException { + table.newFastAppend().appendFile(FILE_A).commit(); + BaseTable baseTable = (BaseTable) table; + HadoopTableOperations tableOperations = (HadoopTableOperations) baseTable.operations(); + + HadoopTableOperations spyOps2 = spy(tableOperations); + doReturn(10000).when(spyOps2).findVersionWithOutVersionHint(any()); + TableMetadata metadataV1 = spyOps2.current(); + SortOrder dataSort = SortOrder.builderFor(baseTable.schema()).asc("data").build(); + TableMetadata metadataV2 = metadataV1.replaceSortOrder(dataSort); + assertThatThrownBy(() -> spyOps2.commit(metadataV1, metadataV2)) + .isInstanceOf(CommitFailedException.class) + .hasMessageContaining("Are there other clients running in parallel with the current task?"); + + HadoopTableOperations spyOps3 = spy(tableOperations); + doReturn(false).when(spyOps3).nextVersionIsLatest(any(), any()); + assertCommitNotChangeVersion( + baseTable, + spyOps3, + CommitFailedException.class, + "Are there other clients running in parallel with the current task?"); + + HadoopTableOperations spyOps4 = spy(tableOperations); + doThrow(new RuntimeException("FileSystem crash!")) + .when(spyOps4) + .renameMetaDataFileAndCheck(any(), any(), any()); + assertCommitNotChangeVersion( + baseTable, spyOps4, CommitFailedException.class, "FileSystem crash!"); + } + + @Test + public void testCommitFailedAndCheckFailed() throws IOException { + table.newFastAppend().appendFile(FILE_A).commit(); + BaseTable baseTable = (BaseTable) table; + HadoopTableOperations tableOperations = (HadoopTableOperations) baseTable.operations(); + HadoopTableOperations spyOps = spy(tableOperations); + doThrow(new RuntimeException("FileSystem crash!")) Review Comment: @Fokko done -- 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. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org