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