mkroll-db commented on code in PR #18203:
URL: https://github.com/apache/iceberg/pull/18203#discussion_r4095150439


##########
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() {

Review Comment:
   I initially created them to test jdbc's concurrent behavior but you're right 
they don't make any sense.
   I removed them in 40c08461c3c768a2d5cdaed6660831076b49596f



##########
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:
   Removed in 40c08461c3c768a2d5cdaed6660831076b49596f



-- 
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]

Reply via email to