LUCENE-7868: fix race condition when reader pooling is disabled

This commit is contained in:
Mike McCandless 2017-07-05 16:53:05 -04:00
parent f0cc3769b5
commit 7c704d5258
2 changed files with 5 additions and 4 deletions

View File

@ -3758,7 +3758,6 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
// and re-resolve against the newly merged segment:
Map<String,List<DocValuesFieldUpdates>> mergingDVUpdates = rld.getMergingDVUpdates();
for (Map.Entry<String,List<DocValuesFieldUpdates>> ent : mergingDVUpdates.entrySet()) {
String field = ent.getKey();
@ -4356,6 +4355,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
// Hold onto the "live" reader; we will use this to
// commit merged deletes
final ReadersAndUpdates rld = readerPool.get(info, true);
rld.setIsMerging();
SegmentReader reader = rld.getReaderForMerge(context);
int delCount = reader.numDeletedDocs();

View File

@ -811,9 +811,10 @@ class ReadersAndUpdates {
synchronized public void setIsMerging() {
// This ensures any newly resolved doc value updates while we are merging are
// saved for re-applying after this segment is done merging:
isMerging = true;
assert mergingDVUpdates.isEmpty();
if (isMerging == false) {
isMerging = true;
assert mergingDVUpdates.isEmpty();
}
}
/** Returns a reader for merge, with the latest doc values updates and deletions. */