aoli-al opened a new issue, #13547:
URL: https://github.com/apache/lucene/issues/13547

   ### Description
   
   The test `testSubclassConcurrentMergeScheduler` is flaky due to concurrency 
issues and produces following assertion failure: 
   
   ```
   java.lang.AssertionError
        at 
__randomizedtesting.SeedInfo.seed([8CC0C37B9C028773:B417ED69822FD77]:0)
        at org.junit.Assert.fail(Assert.java:87)
        at org.junit.Assert.assertTrue(Assert.java:42)
        at org.junit.Assert.assertTrue(Assert.java:53)
        at 
org.apache.lucene.TestMergeSchedulerExternal.testSubclassConcurrentMergeScheduler(TestMergeSchedulerExternal.java:161)
        at 
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at 
com.carrotsearch.randomizedtesting.RandomizedRunner.invoke(RandomizedRunner.java:1758)
        at 
com.carrotsearch.randomizedtesting.RandomizedRunner$8.evaluate(RandomizedRunner.java:946)
        at 
com.carrotsearch.randomizedtesting.RandomizedRunner$9.evaluate(RandomizedRunner.java:982)
        at 
com.carrotsearch.randomizedtesting.RandomizedRunner$10.evaluate(RandomizedRunner.java:996)
        at 
org.apache.lucene.tests.util.TestRuleSetupTeardownChained$1.evaluate(TestRuleSetupTeardownChained.java:48)
        at 
org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
        at 
org.apache.lucene.tests.util.TestRuleThreadAndTestName$1.evaluate(TestRuleThreadAndTestName.java:45)
        at 
org.apache.lucene.tests.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:60)
        at 
org.apache.lucene.tests.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:44)
        at org.junit.rules.RunRules.evaluate(RunRules.java:20)
        at 
com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
        at 
com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:390)
        at 
com.carrotsearch.randomizedtesting.ThreadLeakControl.forkTimeoutingTask(ThreadLeakControl.java:843)
        at 
com.carrotsearch.randomizedtesting.ThreadLeakControl$3.evaluate(ThreadLeakControl.java:490)
        at 
com.carrotsearch.randomizedtesting.RandomizedRunner.runSingleTest(RandomizedRunner.java:955)
        at 
com.carrotsearch.randomizedtesting.RandomizedRunner$5.evaluate(RandomizedRunner.java:840)
        at 
com.carrotsearch.randomizedtesting.RandomizedRunner$6.evaluate(RandomizedRunner.java:891)
        at 
com.carrotsearch.randomizedtesting.RandomizedRunner$7.evaluate(RandomizedRunner.java:902)
        at 
org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
        at 
com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
        at 
org.apache.lucene.tests.util.TestRuleStoreClassName$1.evaluate(TestRuleStoreClassName.java:38)
        at 
com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:40)
        at 
com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:40)
        at 
com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
        at 
com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
        at 
org.apache.lucene.tests.util.TestRuleAssertionsRequired$1.evaluate(TestRuleAssertionsRequired.java:53)
        at 
org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
        at 
org.apache.lucene.tests.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:44)
        at 
org.apache.lucene.tests.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:60)
        at 
org.apache.lucene.tests.util.TestRuleIgnoreTestSuites$1.evaluate(TestRuleIgnoreTestSuites.java:47)
        at org.junit.rules.RunRules.evaluate(RunRules.java:20)
        at 
com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
        at 
com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:390)
        at 
com.carrotsearch.randomizedtesting.ThreadLeakControl.lambda$forkTimeoutingTask$0(ThreadLeakControl.java:850)
        at java.base/java.lang.Thread.run(Thread.java:1583)
   ```
   
   The root cause is that the injected `IOException` in `MyMergeThread` will 
close IndexWriter 
https://github.com/apache/lucene/blob/62e08f5f4b76b84ed4109d8493d1dac2048d3350/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java#L4777
 . 
   
   If this code is executed before `((MyMergeScheduler) 
writer.getConfig().getMergeScheduler()).sync();` at line 
https://github.com/apache/lucene/blob/62e08f5f4b76b84ed4109d8493d1dac2048d3350/lucene/core/src/test/org/apache/lucene/TestMergeSchedulerExternal.java#L145
 The testing thread will not block. And the `assertTrue(excCalled);` check 
might be called before the assignment at line 
https://github.com/apache/lucene/blob/main/lucene/core/src/test/org/apache/lucene/TestMergeSchedulerExternal.java#L77
   
   This might also be the root cause of #11683 and #11653 
   
   You can make the test more reproducible by applying the following patch to 
the `TestMergeSchedulerExternal.java`
   
   ```
   diff --git 
a/lucene/core/src/test/org/apache/lucene/TestMergeSchedulerExternal.java 
b/lucene/core/src/test/org/apache/lucene/TestMergeSchedulerExternal.java
   index 506a76f9989..3510e110659 100644
   --- a/lucene/core/src/test/org/apache/lucene/TestMergeSchedulerExternal.java
   +++ b/lucene/core/src/test/org/apache/lucene/TestMergeSchedulerExternal.java
   @@ -74,7 +74,11 @@ public class TestMergeSchedulerExternal extends 
LuceneTestCase {
    
        @Override
        protected void handleMergeException(Throwable t) {
   -      excCalled = true;
   +        try {
   +            Thread.sleep(10000);
   +        } catch (InterruptedException e) {
   +        }
   +        excCalled = true;
          if (infoStream.isEnabled("IW")) {
            infoStream.message("IW", "TEST: now handleMergeException");
          }
   @@ -141,6 +145,11 @@ public class TestMergeSchedulerExternal extends 
LuceneTestCase {
          // OK
        }
    
   +    try {
   +      Thread.sleep(100);
   +    } catch (InterruptedException ie) {
   +    }
   +
        try {
          ((MyMergeScheduler) writer.getConfig().getMergeScheduler()).sync();
        } catch (
   ```
   
   
   The complete test output: https://pastebin.com/Re8ijFcT
   
   
   
   ### Version and environment details
   
   My lucene commit: 33a4c1d8ef999902dacedde9c7f04a3c7e2e78c9
   JDK version: openjdk 21.0.3 2024-04-16
   OpenJDK Runtime Environment Homebrew (build 21.0.3)
   OpenJDK 64-Bit Server VM Homebrew (build 21.0.3, mixed mode, sharing)
   


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