mirror of https://github.com/apache/lucene.git
LUCENE-2299: don't miss segments in NRT reader if addIndexes is running
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@949976 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d43627afe1
commit
5179757fdd
|
@ -446,6 +446,9 @@ Bug fixes
|
|||
at a performance cost. CachingSpanFilter by default recaches if
|
||||
there are new deletions (Shay Banon via Mike McCandless)
|
||||
|
||||
* LUCENE-2299: If you open an NRT reader while addIndexes* is running,
|
||||
it may miss some segments (Earwin Burrfoot via Mike McCandless)
|
||||
|
||||
New features
|
||||
|
||||
* LUCENE-2128: Parallelized fetching document frequencies during weight
|
||||
|
|
|
@ -163,22 +163,20 @@ class DirectoryReader extends IndexReader implements Cloneable {
|
|||
final int numSegments = infos.size();
|
||||
SegmentReader[] readers = new SegmentReader[numSegments];
|
||||
final Directory dir = writer.getDirectory();
|
||||
int upto = 0;
|
||||
|
||||
for (int i=0;i<numSegments;i++) {
|
||||
boolean success = false;
|
||||
try {
|
||||
final SegmentInfo info = infos.info(upto);
|
||||
if (info.dir == dir) {
|
||||
readers[upto++] = writer.readerPool.getReadOnlyClone(info, true, termInfosIndexDivisor);
|
||||
}
|
||||
final SegmentInfo info = infos.info(i);
|
||||
assert info.dir == dir;
|
||||
readers[i] = writer.readerPool.getReadOnlyClone(info, true, termInfosIndexDivisor);
|
||||
success = true;
|
||||
} finally {
|
||||
if (!success) {
|
||||
// Close all readers we had opened:
|
||||
for(upto--;upto>=0;upto--) {
|
||||
for(i--;i>=0;i--) {
|
||||
try {
|
||||
readers[upto].close();
|
||||
readers[i].close();
|
||||
} catch (Throwable ignore) {
|
||||
// keep going - we want to clean up as much as possible
|
||||
}
|
||||
|
@ -189,13 +187,6 @@ class DirectoryReader extends IndexReader implements Cloneable {
|
|||
|
||||
this.writer = writer;
|
||||
|
||||
if (upto < readers.length) {
|
||||
// This means some segments were in a foreign Directory
|
||||
SegmentReader[] newReaders = new SegmentReader[upto];
|
||||
System.arraycopy(readers, 0, newReaders, 0, upto);
|
||||
readers = newReaders;
|
||||
}
|
||||
|
||||
initialize(readers);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue