RussellSpitzer commented on code in PR #7931:
URL: https://github.com/apache/iceberg/pull/7931#discussion_r1248311556
##########
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCommits.java:
##########
@@ -352,6 +352,49 @@ public void testNoLockThriftExceptionConcurrentCommit()
throws TException, Inter
Assert.assertEquals("New metadata files should not exist", 2,
metadataFileCount(ops.current()));
}
+ @Test
+ public void testLockExceptionUnknownSuccessCommit() throws TException,
InterruptedException {
+ Table table = catalog.loadTable(TABLE_IDENTIFIER);
+ HiveTableOperations ops = (HiveTableOperations) ((HasTableOperations)
table).operations();
+
+ TableMetadata metadataV1 = ops.current();
+
+ table.updateSchema().addColumn("n", Types.IntegerType.get()).commit();
+
+ ops.refresh();
+
+ TableMetadata metadataV2 = ops.current();
+
+
Assertions.assertThat(ops.current().schema().columns().size()).isEqualTo(2);
+
+ HiveTableOperations spyOps = spy(ops);
+
+ // Simulate a communication error after a successful commit
+ doAnswer(
+ i -> {
+ org.apache.hadoop.hive.metastore.api.Table tbl =
+ i.getArgument(0,
org.apache.hadoop.hive.metastore.api.Table.class);
+ String location = i.getArgument(2, String.class);
+ ops.persistTable(tbl, true, location);
+ throw new LockException("Datacenter on fire");
+ })
+ .when(spyOps)
+ .persistTable(any(), anyBoolean(), any());
+
+ Assertions.assertThatThrownBy(() -> spyOps.commit(metadataV2, metadataV1))
+ .hasMessageContaining("Failed to heartbeat for hive lock while")
+ .isInstanceOf(CommitStateUnknownException.class);
+
+ ops.refresh();
+
+ Assertions.assertThat(ops.current())
+ .as("Current metadata should have changed")
Review Comment:
To make this clearer can we instead check that the metadata is the correct
new snapshot? We should be able to get this in our mock.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]