danielcweeks commented on code in PR #18203:
URL: https://github.com/apache/iceberg/pull/18203#discussion_r4074422906
##########
core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalog.java:
##########
@@ -594,6 +600,63 @@ public void testConcurrentCommit() throws IOException {
"Failed to load table db.table from catalog test_jdbc_catalog:
dropped by another process");
}
+ @Test
+ public void testUnregisterRetriesAfterConcurrentCommit() {
+ TableIdentifier tableIdentifier = TableIdentifier.of("db", "table");
+ catalog.createTable(tableIdentifier, SCHEMA,
PartitionSpec.unpartitioned());
+
+ JdbcCatalog unregisteringCatalog = Mockito.spy(catalog);
+ int[] attempts = {0};
+ String[] committedMetadataLocation = {null};
+ Mockito.doAnswer(
+ invocation -> {
+ if (attempts[0]++ == 0) {
+ Table concurrentTable = catalog.loadTable(tableIdentifier);
+ concurrentTable.updateProperties().set("concurrent",
"commit").commit();
+ committedMetadataLocation[0] =
concurrentTable.metadataFileLocation();
+ }
+
+ return invocation.callRealMethod();
+ })
+ .when(unregisteringCatalog)
+ .dropTableIfMetadataMatches(any(TableIdentifier.class),
any(String.class));
+
+ Table unregistered = unregisteringCatalog.unregisterTable(tableIdentifier);
+
+ assertThat(attempts[0]).isEqualTo(2);
+
assertThat(unregistered.metadataFileLocation()).isEqualTo(committedMetadataLocation[0]);
+ assertThat(unregistered.properties()).containsEntry("concurrent",
"commit");
+ assertThat(catalog.tableExists(tableIdentifier)).isFalse();
+ }
+
+ @Test
+ public void testUnregisterStopsAfterRetryTimeout() {
+ TableIdentifier tableIdentifier = TableIdentifier.of("db", "table");
+ catalog
+ .buildTable(tableIdentifier, SCHEMA)
+ .withProperty(TableProperties.COMMIT_NUM_RETRIES, "1")
+ .withProperty(TableProperties.COMMIT_MIN_RETRY_WAIT_MS, "0")
+ .withProperty(TableProperties.COMMIT_MAX_RETRY_WAIT_MS, "0")
+ .withProperty(TableProperties.COMMIT_TOTAL_RETRY_TIME_MS, "0")
+ .create();
+
+ JdbcCatalog unregisteringCatalog = Mockito.spy(catalog);
+ int[] attempts = {0};
+ Mockito.doAnswer(
+ invocation -> {
+ attempts[0] += 1;
+ return 0;
+ })
+ .when(unregisteringCatalog)
+ .dropTableIfMetadataMatches(any(TableIdentifier.class),
any(String.class));
+
+ assertThatThrownBy(() ->
unregisteringCatalog.unregisterTable(tableIdentifier))
+ .isInstanceOf(CommitFailedException.class)
+ .hasMessage("Cannot unregister table db.table: metadata location
changed concurrently");
Review Comment:
There's currently no way to determine that the metadata location changed, so
this test doesn't make sense.
--
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]