LUCENE-3023: push global deletes if no document was flushed during global flush

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/realtime_search@1097510 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Simon Willnauer 2011-04-28 15:39:52 +00:00
parent 3ee258ae1b
commit 726654c1ab
3 changed files with 10 additions and 8 deletions

View File

@ -488,7 +488,7 @@ final class DocumentsWriter {
* two stage operation; the caller must ensure (in try/finally) that finishFlush
* is called after this method, to release the flush lock in DWFlushControl
*/
final boolean flushAllThreads(final boolean flushDeletes)
final boolean flushAllThreads()
throws IOException {
final DocumentsWriterDeleteQueue flushingDeleteQueue;
@ -514,7 +514,7 @@ final class DocumentsWriter {
while (flushControl.anyFlushing()) {
flushControl.waitForFlush();
}
if (!anythingFlushed && flushDeletes) {
if (!anythingFlushed) { // apply deletes if we did not flush any document
synchronized (ticketQueue) {
ticketQueue.add(new FlushTicket(flushingDeleteQueue.freezeGlobalBuffer(null), false));
}

View File

@ -356,7 +356,7 @@ public class IndexWriter implements Closeable {
poolReaders = true;
final IndexReader r;
doBeforeFlush();
final boolean maybeMerge;
final boolean anySegmentFlushed;
/*
* for releasing a NRT reader we must ensure that
* DW doesn't add any segments or deletes until we are
@ -367,8 +367,10 @@ public class IndexWriter implements Closeable {
synchronized (fullFlushLock) {
boolean success = false;
try {
maybeMerge = docWriter.flushAllThreads(applyAllDeletes);
if (!maybeMerge) {
anySegmentFlushed = docWriter.flushAllThreads();
if (!anySegmentFlushed) {
// prevent double increment since docWriter#doFlush increments the flushcount
// if we flushed anything.
flushCount.incrementAndGet();
}
success = true;
@ -391,7 +393,7 @@ public class IndexWriter implements Closeable {
doAfterFlush();
}
}
if(maybeMerge) {
if(anySegmentFlushed) {
maybeMerge();
}
if (infoStream != null) {
@ -2614,7 +2616,7 @@ public class IndexWriter implements Closeable {
synchronized (fullFlushLock) {
try {
maybeMerge = docWriter.flushAllThreads(applyAllDeletes);
maybeMerge = docWriter.flushAllThreads();
success = true;
} finally {
docWriter.finishFullFlush(success);

View File

@ -85,7 +85,7 @@ public class TestPerSegmentDeletes extends LuceneTestCase {
// merge segments 0 and 1
// which should apply the delete id:2
writer.deleteDocuments(new Term("id", "2"));
writer.flush(false, true);
writer.flush(false, false);
fsmp.doMerge = true;
fsmp.start = 0;
fsmp.length = 2;