ConeyLiu commented on code in PR #7931:
URL: https://github.com/apache/iceberg/pull/7931#discussion_r1246161729
##########
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))
Review Comment:
Hi @pvary, this UT is adapted from the above UT and here we commit the
`metadataV2` back to `metadataV1`. And we throw the `LockException` after the
commit succeeded. So the following should be `Current metadata should have
changed`.
--
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]