You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2020/06/16 21:18:55 UTC

[GitHub] [lucene-solr] msfroh commented on a change in pull request #1585: LUCENE-8962: Allow waiting for all merges in a merge spec

msfroh commented on a change in pull request #1585:
URL: https://github.com/apache/lucene-solr/pull/1585#discussion_r441148085



##########
File path: lucene/core/src/java/org/apache/lucene/index/MergePolicy.java
##########
@@ -399,6 +427,23 @@ public String segString(Directory dir) {
       }
       return b.toString();
     }
+
+    /**
+     * Waits if necessary for at most the given time for all merges.
+     */
+    boolean await(long timeout, TimeUnit unit) {
+      try {
+        CompletableFuture<Void> future = CompletableFuture.allOf(merges.stream()
+            .map(m -> m.completable).collect(Collectors.toList()).toArray(new CompletableFuture<?>[0]));
+        future.get(timeout, unit);
+        return true;
+      } catch (InterruptedException e) {
+        Thread.interrupted();

Review comment:
       In my change, I remember I originally tried handling the `InterruptedException` while waiting for the `CountDownLatch` in a similar way, but it caused an intermittent test failure (in `TestIndexWriterWithThreads`, maybe?) You might run into the same test failure once you start calling this `await` method from within `IndexWriter`.
   
   I was able to get the test passing by rethrowing it wrapped in a `ThreadInterruptedException`. 




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

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



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