You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I saw a failure in the test testMaxMergeCount due to concurrency issues.
𞤃𞤮𞤪𞤧𞤮 19, 2024 12:08:03 𞤇𞤎 com.carrotsearch.randomizedtesting.RandomizedRunner$QueueUncaughtExceptionsHandler uncaughtException
WARNING: Uncaught exception in thread: Thread[#25,Lucene Merge Thread #2,5,TGRP-TestConcurrentMergeScheduler]
org.apache.lucene.index.MergePolicy$MergeException: java.lang.RuntimeException: java.lang.AssertionError: count=2 vs maxMergeCount=1
at __randomizedtesting.SeedInfo.seed([852F062F4E7F50BA]:0)
at org.apache.lucene.index.ConcurrentMergeScheduler.handleMergeException(ConcurrentMergeScheduler.java:774)
at org.apache.lucene.index.ConcurrentMergeScheduler$MergeThread.run(ConcurrentMergeScheduler.java:766)
Caused by: java.lang.RuntimeException: java.lang.AssertionError: count=2 vs maxMergeCount=1
at org.apache.lucene.index.TestConcurrentMergeScheduler$3.doMerge(TestConcurrentMergeScheduler.java:372)
at org.apache.lucene.index.ConcurrentMergeScheduler$MergeThread.run(ConcurrentMergeScheduler.java:739)
Caused by: java.lang.AssertionError: count=2 vs maxMergeCount=1
at org.junit.Assert.fail(Assert.java:89)
at org.junit.Assert.assertTrue(Assert.java:42)
at org.apache.lucene.index.TestConcurrentMergeScheduler$3.doMerge(TestConcurrentMergeScheduler.java:347)
... 1 more
The root cause is that a race could happen in the merge method.
The method calls maybeStall to check if the merge should be stalled due to the thread limit. However, the loop will break if mergeSource.hasPendingMerges() returns false. So, a concurrency issue may arise if mergeSource adds new pending merges after this method is evaluated. This will allow ConcurrentMergeScheduler to create more merge threads than specified.
Description
I saw a failure in the test
testMaxMergeCount
due to concurrency issues.The root cause is that a race could happen in the merge method.
lucene/lucene/core/src/java/org/apache/lucene/index/ConcurrentMergeScheduler.java
Lines 569 to 573 in cc3b412
The method calls
maybeStall
to check if the merge should be stalled due to the thread limit. However, the loop will break ifmergeSource.hasPendingMerges()
returns false. So, a concurrency issue may arise ifmergeSource
adds new pending merges after this method is evaluated. This will allowConcurrentMergeScheduler
to create more merge threads than specified.lucene/lucene/core/src/java/org/apache/lucene/index/ConcurrentMergeScheduler.java
Line 618 in cc3b412
Here is the code to reproduce the failure:
With the patch
TestConcurrentMergeScheduler#testMaxMergeCount
will raise assertion failure.Version and environment details
Version: 33a4c1d
The text was updated successfully, but these errors were encountered: