mirror of https://github.com/apache/lucene.git
LUCENE-5330: Fix IndexWriter to process all internal events on getReader / close / rollback
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1539332 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f165031574
commit
50b5e3ec7c
|
@ -191,6 +191,11 @@ Bug Fixes
|
|||
inside ConstantScoreQuery, which now rewrites to a query removing the
|
||||
obsolete QueryWrapperFilter. (Adrien Grand, Uwe Schindler)
|
||||
|
||||
* LUCENE-5330: IndexWriter didn't process all internal events on
|
||||
#getReader(), #close() and #rollback() which causes files to be
|
||||
deleted at a later point in time. This could cause short-term disk
|
||||
pollution or OOM if in-memory directories are used. (Simon Willnauer)
|
||||
|
||||
API Changes:
|
||||
|
||||
* LUCENE-5222: Add SortField.needsScores(). Previously it was not possible
|
||||
|
|
|
@ -394,6 +394,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit{
|
|||
}
|
||||
// Done: finish the full flush!
|
||||
docWriter.finishFullFlush(success);
|
||||
processEvents(false, true);
|
||||
doAfterFlush();
|
||||
}
|
||||
}
|
||||
|
@ -929,6 +930,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit{
|
|||
closeInternal(waitForMerges, true);
|
||||
}
|
||||
}
|
||||
assert eventQueue.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1061,6 +1063,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit{
|
|||
}
|
||||
// finally, restore interrupt status:
|
||||
if (interrupted) Thread.currentThread().interrupt();
|
||||
processEvents(false, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2020,6 +2023,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit{
|
|||
rollbackInternal();
|
||||
}
|
||||
}
|
||||
assert eventQueue.isEmpty() : eventQueue;
|
||||
}
|
||||
|
||||
private void rollbackInternal() throws IOException {
|
||||
|
|
|
@ -1321,6 +1321,7 @@ public class TestIndexWriter extends LuceneTestCase {
|
|||
dir.close();
|
||||
}
|
||||
|
||||
|
||||
public void testDeleteUnusedFiles() throws Exception {
|
||||
for(int iter=0;iter<2;iter++) {
|
||||
Directory dir = newMockDirectory(); // relies on windows semantics
|
||||
|
@ -1350,7 +1351,19 @@ public class TestIndexWriter extends LuceneTestCase {
|
|||
}
|
||||
|
||||
List<String> files = Arrays.asList(dir.listAll());
|
||||
|
||||
assertTrue(files.contains("_0.cfs"));
|
||||
assertTrue(files.contains("_0.cfe"));
|
||||
assertTrue(files.contains("_0.si"));
|
||||
if (iter == 1) {
|
||||
// we run a full commit so there should be a segments file etc.
|
||||
assertTrue(files.contains("segments_1"));
|
||||
assertTrue(files.contains("segments.gen"));
|
||||
assertEquals(files.toString(), files.size(), 5);
|
||||
} else {
|
||||
// this is an NRT reopen - no segments files yet
|
||||
assertEquals(files.toString(), files.size(), 3);
|
||||
}
|
||||
w.addDocument(doc);
|
||||
w.forceMerge(1);
|
||||
if (iter == 1) {
|
||||
|
|
Loading…
Reference in New Issue