vsop-479 commented on code in PR #16889:
URL: https://github.com/apache/lucene/pull/16889#discussion_r4520573649
##########
lucene/core/src/java/org/apache/lucene/index/ConcurrentMergeScheduler.java:
##########
@@ -636,6 +636,17 @@ protected synchronized boolean maybeStall(MergeSource
mergeSource) {
doStall();
}
+ if (mergeThreads.contains(Thread.currentThread()) &&
mergeSource.hasPendingMerges() == false) {
Review Comment:
Producers should also return false when the `maxMergeCount` is reached and
there are no pending merges. There is no work to schedule, so we should stop
scheduling rather than stall the producer.
My suggestion was to keep both checks inside the loop:
```
while (mergeThreadCount() >= maxMergeCount) {
if (mergeThreads.contains(Thread.currentThread())) {
return false;
}
if (mergeSource.hasPendingMerges() == false) {
return false;
}
// Existing stall logic.
}
```
Without the second check,
`TestConcurrentMergeScheduler#testChangeMaxMergeCountyWhileForceMerge` will
deadlocks: the producer stalls during flush, while the merge threads wait for a
latch that the producer releases only after the flush loop.
--
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]