rdblue commented on a change in pull request #3663:
URL: https://github.com/apache/iceberg/pull/3663#discussion_r767314366



##########
File path: core/src/test/java/org/apache/iceberg/hadoop/TestHadoopCommits.java
##########
@@ -419,4 +422,33 @@ public void testCanReadOldCompressedManifestFiles() throws 
Exception {
     List<FileScanTask> tasks = 
Lists.newArrayList(reloaded.newScan().planFiles());
     Assert.assertEquals("Should scan 1 files", 1, tasks.size());
   }
+
+  @Test
+  public void testConcurrentAppend() throws Exception {
+    assertTrue("Should create v1 metadata",
+            version(1).exists() && version(1).isFile());
+    File dir = temp.newFolder();
+    dir.delete();
+
+    Table tableWithHighRetries = TABLES.create(SCHEMA, SPEC, new 
HashMap<String, String>() {
+      {
+        put(TableProperties.COMMIT_NUM_RETRIES, "1000");
+      }
+    }, dir.toURI().toString());
+    int threadsCount = 30;
+    Thread[] threads = new Thread[threadsCount];
+    for (int i = 0; i < threadsCount; i++) {
+      threads[i] = new Thread(() -> 
tableWithHighRetries.newAppend().appendFile(FILE_A).commit());
+      threads[i].start();
+    }
+    Arrays.stream(threads).forEach(t -> {
+      try {
+        t.join();

Review comment:
       I agree in general, but in this case there are a couple of easier 
solutions.
   
   First, these tests already exist for other catalogs so we can adapt them to 
use `HadoopCatalog. This should copy `TestJdbcTableConcurrency` and update it. 
Those tests aren't flaky.
   
   Second, we have a trusted way to run tasks in a thread pool, the `Tasks` 
class that is used all over Iceberg. Using that is a really easy way to run 
tests like this. It is what `TestJdbcTableConcurrency` uses.
   
   If that doesn't work, then a library like Awaitility works for me.




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