You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2021/12/30 21:58:52 UTC

[GitHub] [iceberg] rdblue commented on a change in pull request #3663: Core: Add LockManager to HadoopTableOperations

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



##########
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 ran this locally without the lock manager additions and it failed as 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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org