tang-hi commented on issue #12419:
URL: https://github.com/apache/lucene/issues/12419#issuecomment-1623127458

   In my opinion, this deadlock only occurs at the beginning of program 
execution. As long as you ensure that the IndexWriter is constructed before the 
ConcurrentMergeScheduler, the deadlock situation should not occur.
   
   Do you have a specific scenario where you need to concurrently construct the 
IndexWriter and ConcurrentMergeScheduler at the beginning of the program?
   ```Java
   public static void main(String[] args) throws Exception {
       CountDownLatch startLatch = new CountDownLatch(1);
   
       Thread t1 = new Thread(() -> {
         try {
           new IndexWriter(new ByteBuffersDirectory(), new IndexWriterConfig());
         } catch (IOException e) {
           throw new RuntimeException(e);
         }
       });
   
       Thread t2 = new Thread(() -> {
         try {
           startLatch.await();
           new ConcurrentMergeScheduler();
         } catch (InterruptedException e) {
           throw new RuntimeException(e);
         }
       });
   
       t1.start();
       t2.start();
   
       t1.join();
       System.out.println("Start!");
       startLatch.countDown();
   
       t2.join();
   
       System.out.println("Done");
   
       for(int i = 0; i < 1000; i++) {
         deadlock();
       }
     }
   
     static void deadlock() throws InterruptedException {
       CountDownLatch startLatch = new CountDownLatch(1);
   
       Thread t1 = new Thread(() -> {
         try {
           startLatch.await();
           new IndexWriter(new ByteBuffersDirectory(), new IndexWriterConfig());
         } catch (IOException | InterruptedException e) {
           throw new RuntimeException(e);
         }
       });
   
       Thread t2 = new Thread(() -> {
         try {
           startLatch.await();
           new ConcurrentMergeScheduler();
         } catch (InterruptedException e) {
           throw new RuntimeException(e);
         }
       });
   
       t1.start();
       t2.start();
   
       System.out.println("Start!");
       startLatch.countDown();
   
       t2.join();
       t1.join();
   
       System.out.println("Done");
     }
   
   ```


-- 
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-unsubscr...@lucene.apache.org

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


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

Reply via email to