mirror of https://github.com/apache/lucene.git
LUCENE-4158: leave stall control on each wakeup call to prevent full flush starvation due to queued flushes
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1353433 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fcc0fea1f3
commit
7c26573fe3
|
@ -633,6 +633,12 @@ final class DocumentsWriterFlushControl {
|
|||
* checked out DWPT are available
|
||||
*/
|
||||
void waitIfStalled() {
|
||||
if (documentsWriter.infoStream.isEnabled("DWFC")) {
|
||||
documentsWriter.infoStream.message("DWFC",
|
||||
"waitIfStalled: numFlushesPending: " + flushQueue.size()
|
||||
+ " netBytes: " + netBytes() + " flushBytes: " + flushBytes()
|
||||
+ " fullFlush: " + fullFlush);
|
||||
}
|
||||
stallControl.waitIfStalled();
|
||||
}
|
||||
|
||||
|
|
|
@ -67,17 +67,16 @@ final class DocumentsWriterStallControl {
|
|||
void waitIfStalled() {
|
||||
if (stalled) {
|
||||
synchronized (this) {
|
||||
boolean hasWaited = false;
|
||||
while (stalled) {
|
||||
if (stalled) { // react on the first wakeup call!
|
||||
// don't loop here, higher level logic will re-stall!
|
||||
try {
|
||||
assert hasWaited || incWaiters();
|
||||
assert (hasWaited = true);
|
||||
assert incWaiters();
|
||||
wait();
|
||||
assert decrWaiters();
|
||||
} catch (InterruptedException e) {
|
||||
throw new ThreadInterruptedException(e);
|
||||
}
|
||||
}
|
||||
assert !hasWaited || decrWaiters();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,6 @@ public class TestDocumentsWriterStallControl extends LuceneTestCase {
|
|||
|
||||
Thread[] stallThreads = new Thread[atLeast(3)];
|
||||
for (int i = 0; i < stallThreads.length; i++) {
|
||||
final int threadId = i;
|
||||
final int stallProbability = 1 +random().nextInt(10);
|
||||
stallThreads[i] = new Thread() {
|
||||
public void run() {
|
||||
|
|
Loading…
Reference in New Issue