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



##########
File path: core/src/test/java/org/apache/iceberg/hadoop/TestHadoopCommits.java
##########
@@ -419,4 +429,47 @@ 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 testConcurrentFastAppends() throws Exception {
+    assertTrue("Should create v1 metadata", version(1).exists() && 
version(1).isFile());
+    File dir = temp.newFolder();
+    dir.delete();
+    int threadsCount = 5;
+    int numberOfCommitedFilesPerThread = 10;
+    Table tableWithHighRetries = TABLES.create(SCHEMA, SPEC,
+        ImmutableMap.of(COMMIT_NUM_RETRIES, String.valueOf(threadsCount)), 
dir.toURI().toString());
+
+    String fileName = UUID.randomUUID().toString();
+    DataFile file = DataFiles.builder(tableWithHighRetries.spec())
+        .withPath(FileFormat.PARQUET.addExtension(fileName))
+        .withRecordCount(2)
+        .withFileSizeInBytes(0)
+        .build();
+    ExecutorService executorService = 
Executors.newFixedThreadPool(threadsCount);
+
+    AtomicInteger barrier = new AtomicInteger(0);
+    Tasks
+        .range(threadsCount)
+        .stopOnFailure()
+        .throwFailureWhenFinished()
+        .executeWith(executorService)
+        .run(index -> {
+          for (int numCommittedFiles = 0; numCommittedFiles < 
numberOfCommitedFilesPerThread; numCommittedFiles++) {
+            while (barrier.get() < numCommittedFiles * threadsCount) {
+              try {
+                Thread.sleep(10);
+              } catch (InterruptedException e) {
+                throw new RuntimeException(e);
+              }
+            }
+            tableWithHighRetries.newFastAppend().appendFile(file).commit();
+            barrier.incrementAndGet();
+          }
+        });
+
+    tableWithHighRetries.refresh();
+    assertEquals(threadsCount * numberOfCommitedFilesPerThread,
+        Lists.newArrayList(tableWithHighRetries.snapshots()).size());

Review comment:
       I constantly run with this test failure locally as:
   org.apache.iceberg.hadoop.TestHadoopCommits > testConcurrentFastAppends 
FAILED
       java.lang.AssertionError: expected:<50> but was:<40>
           at org.junit.Assert.fail(Assert.java:89)
           at org.junit.Assert.failNotEquals(Assert.java:835)
           at org.junit.Assert.assertEquals(Assert.java:647)
           at org.junit.Assert.assertEquals(Assert.java:633)
           at 
org.apache.iceberg.hadoop.TestHadoopCommits.testConcurrentFastAppends(TestHadoopCommits.java:472)
   
   1353 tests completed, 1 failed, 21 skipped
   
   Is this expected?




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